Wednesday, January 14, 2015

Overlay Line Plot on Bar Graph Using Different Y-Axes and change the properties of Bar and Line

For Overlay Line Plot on Bar Graph Using Different Y-Axes. See here.

days = 0:5:35;
conc = [515,420,370,250,135,120,60,20];
temp = [29,23,27,25,20,23,23,27];

[AX,hBar,hLine] = plotyy(days,temp,days,conc,'bar','plot'); %u can switch order of 'bar' and 'plot'.

%Change the Axis properties
set(AX(1),'ycolor','r')
set(AX(2),'ycolor','b')

%Change Line properties
set(hLine, 'color', r)

%Change Bar properties
set(hBar, 'facecolor', r)
set(hBar, 'edgecolor', g)

%Transparent bar
ch = get(hBar, 'child')
set(ch, 'facea', 0.5)
Read more ...