6
$\begingroup$

I can create a BarChart with horizontal bars (using BarOrigin -> Left) and Mathematica will automatically position the ChartLabels on the left hand side:

data1D = RandomReal[{1, 10}, 10];
labels = DictionaryLookup["D*", 10];

BarChart[data1D, BarOrigin -> Left, ChartLabels -> labels, 
 BaseStyle -> {FontFamily -> "Calibri", 14}]

enter image description here

However, if I want to plot a stacked chart in the same way, the ChartLabels appear below the bars:

data2D = RandomReal[{1, 10}, {10, 2}];

BarChart[data2D, BarOrigin -> Left, ChartLayout -> "Stacked", 
 ChartLabels -> {labels, None}, 
 BaseStyle -> {FontFamily -> "Calibri", 14}]

enter image description here

How can I get the labels for the stacked chart to appear as they do in the simple chart?

$\endgroup$

1 Answer 1

5
$\begingroup$

Use

 ChartLabels -> {Placed[labels, Axis], None}

enter image description here

$\endgroup$
4
  • $\begingroup$ thank you! I looked at Placed but didn't see Axis in the docs. Accepting immediately as this is 100% what I wanted. $\endgroup$ Commented Nov 23, 2012 at 13:40
  • $\begingroup$ Simon, thank you for the accept. I have been struggling with option combinations BarOrigin/Joined in BarCharts/Histograms; somehow Joined->True works properly only if BarOrigin->Bottom (perhaps due to some corruption in my mma installation). Do you mind checking if Joined->True works as expected in your example? $\endgroup$
    – kglr
    Commented Nov 23, 2012 at 15:56
  • $\begingroup$ I can confirm that Joined->True does not work properly on my example (MMA 8.04). $\endgroup$ Commented Nov 23, 2012 at 19:26
  • $\begingroup$ fixed in version 9. $\endgroup$
    – kglr
    Commented Nov 29, 2012 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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