3
$\begingroup$

NB: For this post, I'll use bar's end as shorthand for the end of the bar that's opposite to the bar's origin.


In bar charts, the Above symbol can be used to position labels right outside the bar's end:

BarChart[{531, 29, 1869}
 , ChartLabels -> {"A", "B", "C"}
 , LabelingFunction -> Above
 , ImageSize -> Small
]

Mathematica graphics

If BarOrigin -> Top, one can get the corresponding effect by using Below instead of Above:

BarChart[{531, 29, 1869}
 , ChartLabels -> {"A", "B", "C"}
 , BarOrigin -> Top
 , LabelingFunction -> Below
 , ImageSize -> Small
]

Mathematica graphics


How can one achieve the same effect when BarOrigin -> Left or BarOrigin -> Right?


To be clear about the desired effect, when BarOrigin -> Left (resp. BarOrigin -> Right), the label should be placed to the right (resp. to the left) of the bar, just outside the bar's end. The label's text should be left-justified (resp. right-justified), but it should have the same font, size, and orientation is it does when LabelingFunction -> Above.

$\endgroup$
  • 1
    $\begingroup$ Have you tried LabelingFunction -> After? $\endgroup$ – Anjan Kumar Feb 16 '17 at 12:48
  • $\begingroup$ Regarding the question you deleted: I was hoping to see an answer to it (after specifying the context where Placed is used). I think it would have been a useful Q/A .... $\endgroup$ – Szabolcs Feb 16 '17 at 13:10
  • $\begingroup$ @Szabolcs: FWIW, I undeleted the question. $\endgroup$ – kjo Feb 16 '17 at 17:27
6
$\begingroup$

Using LabelingFunction with After sets the labels to the rightside of the bar.

BarChart[data, ChartLabels -> {"A", "B", "C"}, BarOrigin -> Left, 
LabelingFunction -> After, ImageSize -> Medium]

enter image description here

Similarly, to get the labels before the bar, use LabelingFunction -> Before.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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