How can I plot boxplots within a line graph?
Mostrar comentarios más antiguos

I have the above line plot that I want to add some box plots onto however the hold on function doesn't seem to work for box plots?
Currently I am plotting the data for the first graph, then using "hold on" and then trying to add several box plots using boxplot([data1,data2],[0,5]). I want this to plot the box plots for data1 and data2 at locations 0 and 5 along the x axis of the first line plot.
Any help is greatly appreciated.
Respuestas (1)
the cyclist
el 27 de Ag. de 2015
The way you have specified [0,5] does not correspond to the correct syntax of the boxplot command. (That will be interpreted as a grouping variable, which is probably why it is not working.)
I believe you want to specify your boxplot as
boxplot([data1,data2],'positions',[0,5])
2 comentarios
Zach
el 27 de Ag. de 2015
Editada: the cyclist
el 27 de Ag. de 2015
the cyclist
el 27 de Ag. de 2015
It's possible that simply doing the boxplots first, then the other, is the simplest way.
If that does not work, then after you do the first plot (but before the boxplot), do
xlim = get(gca,'XLim')
and then after the boxplot, do
set(gca,'XLim',xlim)
and similar for y if you need to.
Categorías
Más información sobre 2-D and 3-D Plots 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!
