【问题标题】:Matlab: boxplot at uneven spacingMatlab:不均匀间距的箱线图
【发布时间】:2019-11-10 14:09:38
【问题描述】:

考虑以下在 Matlab 中绘制箱线图的示例,我取自 here

rng('default')  % For reproducibility
x1 = rand(5,1);
x2 = rand(10,1);
x3 = rand(15,1);
x = [x1; x2; x3];
g1 = repmat({'First'},5,1);
g2 = repmat({'Second'},10,1);
g3 = repmat({'Third'},15,1);
g = [g1; g2; g3];
% Create the box plots.
boxplot(x,g)

上面将以相等的间隔绘制箱线图,为此我可以更改 xticks。我想要的是在不均匀的横坐标值上绘制箱线图,比如说在横坐标 = [1.1, 2.5, 4.6]

谢谢

【问题讨论】:

  • 你不能总是更新'XTickLabels'吗? abscissa = [1.1, 2.5, 4.6]; 那么剧情之后,set(gca,'XTickLabels',abscissa)?这对我有用,但我可能不完全理解您在寻找什么。
  • 感谢@SecretAgentMan 的评论,如果我没有把我的问题说清楚,我很抱歉,但我得到了我想要的东西

标签: matlab boxplot


【解决方案1】:

我明白了,这很简单

abscissa = [1.1, 2.5, 4.6]
boxplot(x, g, 'positions', abscissa , 'labels', abscissa )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-31
    • 2020-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多