How do I pass bar colors to multiple bar series in @bar function?

조회 수: 4 (최근 30일)
Irina
Irina 2018년 9월 13일
I'm trying to plot a line and bar chart on the same graph. On the Left axis I have 2 line plots of series in matrix Y1, on the Right axis a grouped bar of 2 series in Y2. Is there a way to pass bar colors to the 2 series inside the @bar function? Here's the code example:
x1 = [datenum(2010, 1, 1):datenum(2018, 1, 1)]';
Y1 = [log(x1 - x1(1) + 1), 0.5 + log(x1 - x1(1) + 1)];
x2 = datenum(2010:2018, 1, 1)';
Y2 = normrnd(0, 1, 9, 2);
figure
hAx = plotyy(x1, Y1, x2, Y2, @plot, @bar);
hAx(1).XLim = [datenum('1jan10'), datenum('1jan19')];
hAx(1).XTick = [datenum('1jan10'):365:datenum('1jan19')];
hAx(2).XLim = [datenum('1jan10'), datenum('1jan19')];
hAx(2).XTick = [datenum('1jan10'):365:datenum('1jan19')];
datetick('x', 'yy');

답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by