Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
is that cheating? BarChart[{1, 2, 3, 0}, AxesStyle -> Directive[Opacity[0]], Frame -> True]. There must be a smarter way - –  Pinguin Dirk Apr 4 '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 4 '13 at 12:45

3 Answers 3

up vote 2 down vote accepted

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

share|improve this answer
    
Thank you for your idea. Now I'll just customise the chart further, like this. –  Taiki Apr 4 '13 at 15:05

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.

share|improve this answer
    
Thank you. I just updated my question a bit. It seems the option Axes -> False causes the last zero to disappear. –  Taiki Apr 4 '13 at 10:26

Perhaps you could do:

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

Mathematica graphics

Just to be sure

share|improve this answer
    
Thank you. Now I have updated my question. With Axes set to False, the last zero really disappears. –  Taiki Apr 4 '13 at 10:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.