How to create a stacked bar plot with error bars?

4 次查看(过去 30 天)
Hello,
I have a set of data split into two uneven categories. Each category contains measurements for three variables: total, organic and inorganic.
I would like to create a stacked bar plot (with a single bar on the xaxis for each category). Within each bar, I would like to plot the organic and inorganic values as stacked. If possible, I would also like to have an error bar appear at the top of each bar displaying +/- 1 standard deviation for the averaged total.
I tried by starting to plot one of the values in a bar graph, and received an error that xdata cannot contain duplicate values:
x = B(1:59,3) %Where B is the predefined excel file; B(1:36,3) = 1 and B(37:59,3) = 2
T = B(1:59,9) %Total values
O = B(1:59,10) %Organic values
I = B(1:59,8) %Inorganic values
for x = B(1:36,3)
y = (1:36,10) %Organic values
figure(1)
bar(x,y1)
end
Any suggestions or insight are welcome; this is my first time attempting a simple bar plot.
Cheers
  1 个评论
Star Strider
Star Strider 2017-12-2
Please provide an illustration of the sort of plot you want as the result.
The reason for asking is that standard error (or confidence interval) bars on a stacked bar plot would be difficult for someone looking at the plot to interpret. A reviewer/referree (and I have been one) might not accept a paper with confusing graphics.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by