I use this to create a Bar 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
The problem is that some of the data values are 0 and BarChart
won't even add labels for them. Instead it leaves a open space. How can I get it to still add the labels even though the values are 0?
This is with Mathematica 8.
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"]
It seems that "Before" doesn't and "Axis" does work?
The simplest approach is to use a hack like data /. {(0|0.0) -> 0.00001}
.
I think this should work without the need for a hack, so you should also file a report with [email protected].
Your code works as given 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"
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With