4
$\begingroup$

In this BarChart:

BarChart[{573, 604, 519},
 FrameLabel -> {"", ""},
 ChartLabels -> Placed[Rotate[#, 90 Degree] & /@ {"a", "b", "c"}, Top],
 PlotRange -> {All, {400, 600}},
 Frame -> True,
 FrameTicks -> {None, Automatic},
 BaseStyle -> {FontSize -> 22, FontFamily -> "Arial", Black},
 BarSpacing -> {0.1, 0.5},
 FrameStyle -> Directive[Black, AbsoluteThickness[3]],
 PlotRangeClipping -> True]

I would like to see the labels positioned at the same height, let us say 500. How can it be done?

$\endgroup$

1 Answer 1

6
$\begingroup$

1. Post-process to modify label positions

A quick hack: With bc = BarChart[...] from your post:

ReplaceAll[Text[t_, Offset[o_, {x_, y_}], b___] :> 
   Text[t, Offset[o, {x, 500}], b]] @ bc

enter image description here

2. Use the option LabelingFunction:

This, hopefully, is more flexible and robust:

labelingFunction[pos_ : 500] := Placed[#3[[2, 1]], 
   {.5, pos / #}, Rotate[#, 90 Degree] &] &;

Add the option LabelingFunction -> labelingFunction[] to BarChart[...] to get

enter image description here

Use LabelingFunction -> labelingFunction[550]

enter image description here

3. Use Labeled to wrap input data:

labeleddata = MapThread[
   Labeled[#, Rotate[#2, 90 Degree], {.5, 500/#}] &]@
 {{573, 604, 519}, {"a", "b", "c"}};

Use labeleddata as input data and remove the option ChartLabels -> ... from BarChart[...] to get

enter image description here

$\endgroup$

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.