2

Creating a BarChart with {1, 2, 3, 0} as

BarChart[{1, 2, 3, 0}, Axes -> False, Frame -> True]

gives me only the first three bars, a chart identical to just

BarChart[{1, 2, 3}, Axes -> False, Frame -> True]
  1. Is this an intended behaviour or a bug?

  2. (Originally I asked for a workaround. I think I can just use Axes instead of Frame. Let me ask this instead for the sake of knowledge.) What to do if I need Frame but not Axes?

I'm using Mathematica 9.

Taiki
  • 5,259
  • 26
  • 34
  • is that cheating? BarChart[{1, 2, 3, 0}, AxesStyle -> Directive[Opacity[0]], Frame -> True]. There must be a smarter way - – Pinguin Dirk Apr 04 '13 at 11:23
  • Your workaround is great. I think you have answered Question 2! Could you please post it as an answer so I can mark the question as solved? – Taiki Apr 04 '13 at 12:45

3 Answers3

2

Are you sure it's not there? I get this picture:

enter image description here

What appears to be nothingness attached on the end is really a bar of height zero. You can see this more clearly if you do it in 3D

BarChart3D[{1, 2, 3, 0}]

which gives

enter image description here

Now you can see the stump of the zero bar. Another way to see it would be:

BarChart[{1, 2, 3, 0}, LabelingFunction -> (Placed[#, Above] &)]

enter image description here

which labels things with the number.

bill s
  • 68,936
  • 4
  • 101
  • 191
  • Thank you. I just updated my question a bit. It seems the option Axes -> False causes the last zero to disappear. – Taiki Apr 04 '13 at 10:26
2

I cannot answer why this is happening. Intuitively, I interpret BarChart as a chart with no "real", scaled, x-axis. Thus, a frame does not really make a lot of sense to me (with ticks)...

Nevertheless, you could use the following work-around to make the axis "vanish":

BarChart[{1, 2, 3, 0}, AxesStyle -> Directive[Opacity[0]], Frame -> True]

This will keep the last (zero) bar:

enter image description here

Pinguin Dirk
  • 6,519
  • 1
  • 26
  • 36
0

Perhaps you could do:

GraphicsRow[BarChart[#, AxesOrigin -> {0, -1}] & /@ {{1, 2, 3, 0}, {1, 2, 3}}]

Mathematica graphics

Just to be sure

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
  • Thank you. Now I have updated my question. With Axes set to False, the last zero really disappears. – Taiki Apr 04 '13 at 10:39