Error bars with categorical data type

5 次查看(过去 30 天)
L'O.G.
L'O.G. 2022-11-28
评论: L'O.G. 2022-11-28
I am trying to plot error bars in y for data that are categorial type in x. I get an error message saying
Error argument 'err' must be empty when the data are categorical.
How can I plot the error bars in y? I feel like the type in x shouldn't matter.
I am attempting this by
scatter(x,y)
errorbar(x,y,err_in_y);

回答(1 个)

Steven Lord
Steven Lord 2022-11-28
Let's say that your categorical x data contains values apple, banana, and cherry. When the error bars are plotted with errorbar, the caps of the bars do have some width. So how wide should the cap of the error bar for banana be? Halfway between apple and banana to halfway between banana and cherry? How should that be specified?
I suspect that cap width issue is the reason why the err input argument is not supported for categorical data.
  1 个评论
L'O.G.
L'O.G. 2022-11-28
Thanks @Steven Lord to keep with the analogy, if they are different types of apples and you're plotting a quantity to compare between them, then how do you plot the error in that case? Would using something other than categorical be recommended?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by