Boxplot (with several groups/days) + Plot (for each group/day)
Mostrar comentarios más antiguos
Dear All,
I need to plot several groups (g), for several different days (m) on a bar graph. I can do this with the following code:
Y = round(rand(m,g)*10);
bar(Y, 'group');
In addition to this, I want to plot a time-series to each group/day. The array which I want to add to this graph is also an array of size (m*g). This is illustrated if I had one day having 8 groups (i.e. m=1, g=8) at this address: http://www.mathworks.co.uk/help/matlab/creating_plots/bar-and-area-graphs.html, under the heading "Overlaying a Line Plot on the Bar Graph", but how we can do it if we have several days? I am thinking, I have to use plotyy at some point, but my several desperate attempts did not work?!
Lastly, could you also please help me to set the colors of each group?
Regards, Berk
1 comentario
Berk
el 10 de Oct. de 2012
Respuesta aceptada
Más respuestas (3)
Berk
el 10 de Oct. de 2012
0 votos
Tom Lane
el 11 de Oct. de 2012
Here's how you can set the color of the first group:
h = bar(Y, 'group');
set(h(1),'FaceColor','r')
If you are content with separate axes, here's how you can make sure all axes have the same y limits:
h1 = subplot(1,2,1); plot(rand(4,1))
h2 = subplot(1,2,2); plot(2*rand(4,1))
linkaxes([h1 h2],'y')
set(h1,'ylim',[0 2])
Otherwise, if you want to put stuff on the same graph, you'll need to determine the coordinates of each individual bar. Here's how to get started with that:
get(get(h(1),'Children'),'XData')
Berk
el 11 de Oct. de 2012
0 votos
Categorías
Más información sobre Two y-axis en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
