我们可以减少Mathematica中BarChart的条形尺寸宽度吗?

时间:2011-09-15 21:43:43

标签: formatting wolfram-mathematica bar-chart

dalist = {901, 503, 522, 1305} 

cogColors = {RGBColor[0, 0, 1], RGBColor[1, 0, 0], RGBColor[0, 1, 0], RGBColor[1, 1, 0]}

BarChart[dalist, ChartStyle -> cogColors] 

enter image description here

是否可以减小条宽?

4 个答案:

答案 0 :(得分:4)

您可以增加条形间距,而不是更改条形图宽度。

BarChart[dalist, ChartStyle -> cogColors, BarSpacing -> 1]

Bar chart with greater spacing

答案 1 :(得分:4)

BarChart并不打算这样做。您只能更改间距。

如果需要更精细的控制,请使用RectangleChart:

RectangleChart[{{{1, 1}, {1, 1}, {1, 1}}, {{2, 2}, {2, 2}, {2, 2}}}]

enter image description here

答案 2 :(得分:4)

我可能会忽略这一点,但你不能仅仅改变宽高比吗?

BarChart[dalist, ChartStyle -> cogColors, AspectRatio -> 3, ImageSize -> 120]

enter image description here

答案 3 :(得分:2)

见Heike对我earlier question的回答。您需要使用RectangleChart。如果你想在条形中心之间保持一个恒定的距离,以便条形加间距占据一个恒定的空间,你可以使用ChartElementFunction选项和辅助函数,如Heike的答案所示。 (这也可以使用BarChart执行您想要的操作,但我仍然建议使用RectangleChart。)