plotyy line width and color - with multiple lines
Show older comments
Hi Everyone, I know there are posts on similar lines but I am having difficulty specifically with plotyy in which I have multiple lines plotted on the left hand axis, with one plotted on the right hand axis. I thought I knew how to set axis properties but when I set the line width it sets the width of the box around the axis! Also I am trying to define the colours of each of the lines but it is just making the whole background of the plot blue. I think there must be another layer of handles I'm missing? I've only tried this in the first plot of a subplot.
% %define colours
% colorspec=[0 0 1];[0 1 1];[1 0 0];[1 0 1];[0 0.6 0.4];[1 0.4 0];[0.6 0 0.8];[0 1 0.4];[0 0 0.4];[0.8 0 0.2];[1 0.6 0.2];[0 0.6 1];[0 0.2 0];[0.4 0 0.6];[1 0.6 1];[0.8 1 0.4];[0.8 0.6 0.2];[1 0.8 0];[0.6 0 0.2];[0.6 0.6 0.8];[0.2 0.2 0.4];
%
%
% %Both 2010 and 2011 July velocities
% subplot(2,2,1)
% %horizontal velocities sigma 2010 July
%
% [haxes,hline1,hline2]=plotyy(hvel_July_2010_sigma(2:8,1),hvel_July_2010_sigma(2:8,3:22),hvel_July_2010_sigma(2:8,1),hvel_July_2010_sigma(2:8,27));
% axes(haxes(1))
% ylabel('Horizontal velocity (\sigma)');
% xlim([212 218]);
% set(haxes(1),'XTick',[212:218]);
% set(haxes(1),'XTickLabel',{'31/07/10','01/08/10','02/08/10','03/08/10','04/08/10','05/08/10','06/08/10'});
% set(haxes(1),'LineWidth',2);
% set(haxes(1),'Color',colorspec);
% %set(haxes(1),'YTick',[-2 -1 0 1 2]);
% axes(haxes(2))
% ylabel('Discharge (m^3 s^-^1)');
% xlim([212 218]);
% set(haxes(2),'XTick',[212:218]);
% set(haxes(2),'XTickLabel',{'31/07/10','01/08/10','02/08/10','03/08/10','04/08/10','05/08/10','06/08/10'});
Any help with this much appreciated! I am working in Matlab 2010b. The data is attached.
Kind Regards, Cat
Accepted Answer
More Answers (1)
dpb
on 28 Jul 2015
0 votes
The line properties are associated with the line handles, not those of the parent object. In plotyy, they are returned in the two second optional return variables, that you returned has hline1, hline2 for the left- and right-hand axes, respectively. Set the properties for those as desired.
Categories
Find more on Two y-axis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!