Mathematica Asked by JavaCake on February 25, 2021
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 values
on top of each bar?
BarChart[Labeled[#, {#, #2}, {Above, Below}] & @@@ Thread[{values, Most@labels}],
ChartStyle -> "Pastel",
AxesLabel -> {"Year", "Diagnosis"}, Background -> Transparent,
BaseStyle -> {12, FontFamily -> "Helvetica"}, ImageSize -> 600]
Correct answer by kglr on February 25, 2021
This is a bit hackish, but it is convenient in this case:
BarChart[
AssociationThread[labels, values],
ChartLabels -> Automatic,
LabelingFunction -> Above
]
Answered by Szabolcs on February 25, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP