Multiple Plots on Single Figures in Loop

조회 수: 10 (최근 30일)
MustangManiac
MustangManiac 2019년 1월 24일
댓글: Kevin Phung 2019년 1월 24일
Hello - I currently have large datasets that makes loading them all first inpractical. So I created a large loop that will go through and plot everything I need from the first dataset, then delete that from memory, and load the next data set. It will put the plots on the same Figure (#) as the prior data set so I get a series of Figures with many plots across multiple sets of data.
However, I'm trying to add titles to the figures (not above the actual plot, but so that plot browser show's a description instead of Figure 1, 2, etc. , but now it creates a new figure each time through the loop with another data set.
plotbrowser('on') %turn plot browser on
figure (1) %Plot vehicle speed trace
figure('Name', 'Vehicle Speed','NumberTitle','off'); <--- If I comment this out it functions correctly, but the figures are missing titles I desire.
title('Vehicle Speed Trace');
hold on
  댓글 수: 2
Kevin Phung
Kevin Phung 2019년 1월 24일
'It will put the plots on the same Figure (#) as the prior data set so I get a series of Figures with many plots across multiple sets of data.'
are you plotting on the same axes, creating new axes on the same figure, or are you creating a new figure along with a new figures.
MustangManiac
MustangManiac 2019년 1월 24일
Mulitple sets of data on the same plot with the same axis.

댓글을 달려면 로그인하십시오.

답변 (1개)

Kevin Phung
Kevin Phung 2019년 1월 24일
편집: Kevin Phung 2019년 1월 24일
figure()
will automatically create a new figure.
figure (1) %Plot vehicle speed trace
figure('Name', 'Vehicle Speed','NumberTitle','off'); <--- If I comment this out it functions correctly, but the figures are missing titles I desire.
^ you are creating two figures here.
What I would do is assign handles to the figures, and I can always refer back to them elsewhere in my code. Assigning handles/tags to your axes can help in referring to them too.
for example:
f= figure
set(f,'Name','VehicleSpeed','NumberTitle','off')
let me know if this helps.
  댓글 수: 4
MustangManiac
MustangManiac 2019년 1월 24일
편집: MustangManiac 2019년 1월 24일
plotbrowser('on') %turn plot browser on
figure (1) %Plot vehicle speed trace
% figure('Name', 'Vehicle Speed','NumberTitle','off');
title('Vehicle Speed Trace');
hold on
VehSpeed_Interp = interp1(Data.test_data(index).data.time, Data.test_data(index).data2.vspd_corrected, TimeIndex);
a1 = plot(TimeIndex,VehSpeed_Interp); %Plot
legend (a1,l1);
legend('
This is what each figure in the loop is basically like.
');
Kevin Phung
Kevin Phung 2019년 1월 24일
what confuses me is your goal: you want to plot data sets in a loop but have them erased before each new iteration.. your end result is just going to be a plot of whatever your last data set is.
Can you try to not call out the figure in the loop?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by