我有三个变量,我想绘制成一个数字(温度,盐度,叶绿素)。数据被分成两个变量“羽流”和"P7_3m“。它们都是具有列向量的8X5矩阵,
[date salinity temperature attenuation chlorophyll]. 我成功地使用了http://www.mathworks.com/matlabcentral/fileexchange/9016-addaxis的ADDAXIS。
问题是,我想为这三个变量中的每一个绘制两条颜色相同的线条(一条是实心的,另一条是虚线),以便在羽流和P7_3m之间进行比较。X轴是"xt“,并加上”月份“的标签。下面是我的代码,但不起作用,因为在使用ADDAXIS之后,轴句柄返回到最初的第一个绘图轴。是否有方法访问ADDAXIS绘制的轴?这样我就可以在ADDAXIS创建的实线的同一轴上绘制虚线?
我很感谢你的帮助和时间。提前谢谢你!
阿雅
figure; % 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
hold on
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)')发布于 2014-09-08 08:14:20
看起来您需要使用addaxisplot。这应该可以做到:
figure; % start making the figure
ss=20; % setting up the plot
set(0,'DefaultAxesFontSize', ss)
set(0,'DefaultLineLineWidth',3)
hold on
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 on first axis.
plot(xt,plume(:,2),'b') % plot first plot, salinity
plot(xt,P7_3m(:,2),'--b')
set(gca,'XColor','k','YColor','b')
% Plot on second axis.
addaxis(xt,plume(:,3),'r')
addaxisplot(xt,P7_3m(:,3),2,'--r')
% Plot on third axis.
addaxis(xt,plume(:,5),[0 12],'color',[0 0.5 0])
addaxisplot(xt,P7_3m(:,5),3,'--','color',[0 0.5 0])
% Add labels.
xlabel('months')
addaxislabel(1, 'Practical Salinity')
addaxislabel(2, 'Potential Temperature (^{\circ}C)')
addaxislabel(3, 'Chlorophyll a Fluorescence (ug/l)')顺便说一句,如果你做一个独立的例子,这真的很有帮助。在这种情况下,如果您包含一些plume和P7_3m的虚拟数据,那就太好了。在这个例子中,这不是什么大问题,就像你描述的那样,我只是用兰特来生成一些东西,但也许将来会有所帮助。
https://stackoverflow.com/questions/25719712
复制相似问题