how to plot multiple plots on one figure
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi I am fairly new to matlab and I am having trouble plotting. So I'd like to plot multiple plots on one figure. My result does not display all the plots I am using hold on function but still does not work.
here is my code for my plots
figure();
plot(LN(:,N),LT(:,N),'r-');hold on;
plot(LN(:,B),LT(:,B),'r-');hold on;
load coast
axesm('MapProjection','eqdcylin','Frame','on', 'MapLatLimit',latlim,'MapLonLimit',lonlim,'Grid','on')
hold on;
pcolorm(y,x,precipUS);shading interp;
tightmap
colormap('Jet');
caxis([0 10]);
colorbar;
set(gca,'fontsize',10)
set(gcf,'color','w')
hold on;
plotm(lat,long,'k')
plabel;
mlabel;
0 Commenti
Risposte (1)
dpb
il 9 Ago 2016
Modificato: dpb
il 10 Ago 2016
I don't have it to be able to test, but most of your problem is probably related to the fact you have two axes, not just one; the first call to line creates an axes object onto which to plot those lines but then a little later on you call axesm which creates a second axes with some specific properties for maps. Most likely it will have default 'color' property and that will hide the early axes "underneath" it; multiple axes plot routines like plotyy create the second axes to overlay the first but set 'color','none' so it will not obscure the previous.
I suspect to solve your problem all you need to do is to reorder the sequence...
figure
load coast
hAm=axesm('MapProjection','eqdcylin','Frame','on', ...
'MapLatLimit',latlim,'MapLonLimit',lonlim,'Grid','on'); % make map axes, keep handle
hSm=pcolorm(y,x,precipUS);shading interp; % surface of precip data
hold on % add some stuff to this axes now
hLm=plotm(lat,long,'k'); % first some map lines
hL=plot(LN(:,[N B]),LT(:,[N B]),'r-'); % then some plot lines
tightmap % make some cosmetic changes...
colormap('Jet');
caxis([0 10]);
colorbar;
set(hAm,'fontsize',10,'color','w')
plabel;
mlabel;
There may be issues with the axes limits if the x/y data for the line plot don't match up with the lat/lon data for the map. If that's so, would need to create a second axes with appropriate limits but then the aforementioned "trick" of 'color','none' would be needed and also would need to keep both axes handles to be able to control each. If this comes to pass, post back and can lead you through the process (or open and read the doc under Graphics on multiple axes; it shows an example of how to do so).
But, the above caveat aside, I believe the above will show all the plots because they're all being placed on the one axes object, now.
Oh, one final point...once you call hold on once for a given axes, calling it again won't make the condition an "on-er"; it's a flag and is either on or off.
2 Commenti
Image Analyst
il 10 Ago 2016
I'm not sure they understand yet the difference between a "figure" and an "axes". Plots and images happen only in axes controls. A figure by itself does not have plot(s) on it, but a figure may have one or multiple axes on the figure, and it's the axes on the figure that actually contain the plots and/or images.
From the original wording, I'm not sure if they want one figure with one axes and multiple curves in that axes, or if they want multiple axes on the figure with one curve per axes control.
dpb
il 10 Ago 2016
Hmmm....guess that's possible; I just thought the problem was some lines weren't showing that were plotted and (again I don't have Mapping Toolbox so can test for certain) figure the issue is that the second axes created is occluding the first...
Guess we'll find out (maybe, seems like many of whom I've responded to lately never indicate they ever came back... :( )
Vedere anche
Categorie
Scopri di più su Geographic Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!