3
$\begingroup$

I am creating a BarChart, where i wish to have the actual value on the top of each bar and the label of the bar on the bottom. Basically i have created the BarChart with the label in the bottom, but i cannot figure out how to add the value on the top of each bar.

values = {150445, 161419, 173986, 202405, 214516, 227004, 
   240700, 256377, 271309, 286944, 307016, 320545};
labels = {2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
    2009, 2010, 2011, 2012};
Show[
 BarChart[values, ChartLabels -> labels, 
  ChartStyle -> "Pastel", AxesLabel -> {"Year", "Diagnosis"}],
 Background -> Transparent,
 BaseStyle -> {12, FontFamily -> "Helvetica"},
 ImageSize -> 600
 ]

Is there a way to view the valueson top of each bar?

$\endgroup$
1
  • 1
    $\begingroup$ From related Q/A: BarChart[Labeled[#, #, Above] & /@ values, ChartLabels -> labels, ChartStyle -> "Pastel", AxesLabel -> {"Year", "Diagnosis"}]. $\endgroup$
    – kglr
    Commented Jun 18, 2014 at 13:50

2 Answers 2

5
$\begingroup$
 BarChart[Labeled[#, {#, #2}, {Above, Below}] & @@@ Thread[{values, Most@labels}],
   ChartStyle -> "Pastel", 
   AxesLabel -> {"Year", "Diagnosis"}, Background -> Transparent, 
   BaseStyle -> {12, FontFamily -> "Helvetica"}, ImageSize -> 600]

enter image description here

$\endgroup$
1
$\begingroup$

This is a bit hackish, but it is convenient in this case:

BarChart[
 AssociationThread[labels, values],
 ChartLabels -> Automatic,
 LabelingFunction -> Above
]
$\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.