How to stop barchart from hiding labels for data value 0 in Mathematica?

I use this to create a chart:

BarChart[ Reverse@data , BarOrigin -> Left, ChartLabels -> Placed[{ Reverse@labels , Reverse@data }, {Before, After}], ChartElementFunction -> "FadingRectangle" ] 

With data = {7, 10, 0, 6, 0, 3, 5} this gives

Mathematica graphics

The problem is that some of the data values ​​are 0, and BarChart will not even add labels for them. Instead, it leaves open space. How can I make it still add labels, even if the values ​​are 0?

This is with Mathematica 8.

+7
source share
3 answers

What about

 data = {7, 10, 0, 6, 0, 3, 5} labels = ("label " ~~ ToString[#]) & /@ data BarChart[ Reverse@data , BarOrigin -> Left, ChartLabels -> Placed[{ Reverse@labels , Reverse@data }, {Axis, After}], ChartElementFunction -> "FadingRectangle"] 

Does "Before" seem to work and "Axis" works?

chart

+6
source

The easiest way is to use a hack as data /. {(0|0.0) -> 0.00001} data /. {(0|0.0) -> 0.00001} .

I think this should work without the need for hacking, so you should also file a report using support@wolfram.com.

+3
source

Your code works as specified in Mathematica 7 on Windows 7.

 data = {7, 10, 0, 6, 0, 3, 5}; labels = Row[{"label",#}]& /@ data; BarChart[ Reverse@data , BarOrigin -> Left, ChartLabels -> Placed[{ Reverse@labels , Reverse@data }, {Before, After}], ChartElementFunction -> "FadingRectangle" ] 

Mathematica graphics

+2
source

All Articles