How can I plot boxplots within a line graph?
18 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
the cyclist
2015-8-27
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 个评论
the cyclist
2015-8-27
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!