plotyy - how to change line width, colour and xaxis labels
이전 댓글 표시
Hi all,
I am trying to use the plotyy function to plot a bar chart with a line graph on top. Generally I have managed to achieve what I was after but would also like to change the line thickness (the hLine.LineWidth = 3; doesn't seem to work), the colour (ditto with hLine.Color = [159/255 20/255 124/255; 70/255 32/255 112/255];) and the xaxis labels are displaying correctly but underneath are the values 1,2,3, etc. This is my code
figure
set(0,'DefaultAxesFontName', 'Aller')
[ax,hBar,hLine]=plotyy(1:13,[aircraft.median_2011;aircraft.median_2013]', ...
1:13,[aircraft.count_2011;aircraft.count_2013]', ...
'bar','semilogy')
legend('2011','2013')
ylabel(ax(1),'Joining Point (nm)')
ylabel(ax(2),'No. of Flights')
str = [aircraft.name];
set(gca, 'XTickLabel',str, 'XTick',1:numel(str));
barmap=[159/255 20/255 124/255; 70/255 32/255 112/255]; %[0.7 0.7 0.7] is grey, [ 0.05 .45 0.1] is green
colormap(barmap);
hLine.LineWidth = 3;
hLine.Color = [159/255 20/255 124/255; 70/255 32/255 112/255];
If anyone knows how to do any of these help would be very much appreciated.
Cheers
댓글 수: 2
Robert Cumming
2015년 1월 5일
what version of matlab?
any error message(s)?
Also - we dont have your aircraft variable to recreate your plots exactly.
Mike Garrity
2015년 1월 6일
I think that it should have reported the following error
Incorrect number of right hand side elements in dot name assignment. Missing []
around left hand side is a likely cause.
That's not as helpful as it could be. It's really the left hand side that's the issue here.
채택된 답변
추가 답변 (1개)
Mike Garrity
2015년 1월 6일
0 개 추천
Because each of your two plots contains two series, the variable hLine is an array of two line objects. Unfortunately, dot notation doesn't work on arrays of objects yet. That means that you need to use set like dpb showed above.
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!