How do I pass bar colors to multiple bar series in @bar function?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Bar Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!