Two plots per axis using addaxis
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dear Matlab users,
I have three variables I want to plot in one figure (temperature, salinity, chlorophyll). The data is split into two variables "plume" and "P7_3m". They are both 8X5 matrices with column vectors,
[date salinity temperature attenuation chlorophyll].
The problem is I want to plot two lines (one solid, another dashed) of the same color for each of the three variables to compare among plume vs P7_3m. The x-axis is "xt" and labeled with "months". Below is the code I have and does not work because after the use of ADDAXIS, the axes handle goes back to the original first plot axis. Is there a way to access the axis plotted by ADDAXIS? So I can plot my dashed line on the same axis as the solid line created by ADDAXIS?
I'd appreciate your help and time. Thank you in advance!
Aya
figure; hold on % start making the figure
ss=20; % setting up the plot
set(0,'DefaultAxesFontSize', ss)
set(0,'DefaultLineLineWidth',3)
months={'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug'}; % x axis
xt=[1:length(months)];
set(gca,'xtick',xt)
set(gca,'xticklabel',months, 'fontsize', ss)
plot(xt,plume(:,2),'b') % plot first plot, salinity
plot(xt,P7_3m(:,2),'--b')
haxes1 = gca;
set(haxes1,'XColor','k','YColor','b')
addaxis(xt,plume(:,3),'r')
plot(xt,P7_3m(:,3),'--r')
addaxis(xt,plume(:,5),[0 12],'color',[0 0.5 0])
plot(xt,P7_3m(:,5),'color',[0 0.5 0])
xlabel('months')
ylabel('Practical Salinity')
addaxislabel(2,'Potential Temperature (^{\circ}C)')
addaxislabel(3, 'Chlorophyll a Fluorescence (ug/l)')
0 Commenti
Risposte (1)
Salaheddin Hosseinzadeh
il 7 Set 2014
Hi Aya,
use hold on after you crate your axis not after figure
hold on works on axis, look at the MATLAB documentation.
hold(axis_handle,'on');
doc hold
You used hold on before defining or creating an axis, I don't think it that would do anything at all. Move hold on to the next line after the first plot command, plot command automatically creates an axis if one doesn't exist, and hold on will effect the existing axis created by plot.
I had a look at your code and it should be ok I guess.
I never happened to use addaxis though, I don't know what's that, probably a code developed by someone and not MATHWORKS. I believe the only reason you're using addaxis is that simple problem you made(placing hold on before plot)
You're not into doing something complicated and I'm sure you can do it needless of addaxis.
Good Luck!
Vedere anche
Categorie
Scopri di più su Polar Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!