Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Plot clearing with hold on

  1. Nov 17, 2013 #1
    I am creating a plot in a for loop adding each iteration to the plot in matlab. This part works fine but after the for loop, i am trying to format the title and axis and that is clearing the plot. I can add the legend without it clearing. I also tried hold all but that did not work either. Any tips to get the formatting addition to not clear the plot?

    this is the plot that is in the for loop:

    plot(W,M,'color',[1-ii/10 ii/10 1]); hold on

    Then after the for loop:
    Code (Text):

    axis([0 2500 0 1.1])
    xlabel('Frequency (Hz)');
    ylabel('Magnitude'); grid on
    I can add the legend without it clearing if i comment out the code above.

    Code (Text):

    legend(['F_c= ',int2str(fb(1)),' Hz'],['F_c= ',int2str(fb(2)),' Hz'],... % Creates the legend of the plot.
    ['F_c= ',int2str(fb(3)),' Hz'],['F_c= ',int2str(fb(4)),' Hz'],...
    ['F_c= ',int2str(fb(5)),' Hz'],['F_c= ',int2str(fb(6)),' Hz'],...
    ['F_c= ',int2str(fb(7)),' Hz'],['F_c= ',int2str(fb(8)),' Hz']);

  2. jcsd
  3. Nov 17, 2013 #2
    Sorry, never mind... had my axis scale off and it was just shifted off plot..
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Plot clearing with hold on
  1. Plotting with MATLAB (Replies: 1)

  2. Interactive Plotting (Replies: 2)

  3. Plotting bands (Replies: 2)