# How to make an Histogram where the data are strings? [duplicate]

Histogram[{3, 3, 2, 2, 2, 2, 2, 1, 1}] works great to give you an histogram in which mathematica counts the occurence of each number and makes the plot. Is there a variant for non-numeric data? Say I want to count and make an histogram on strings

Histogram[{"a", "a", "b", "c"}]

or even more general

Histogram[{a, a, b, c}]

where a,b, and c are (so far unassigned) symbols.

Is there a way to get this histogram from built-in functions?

• BarChart[#[], ChartLabels -> #[]] &@ Transpose@Sort@Tally@{a, a, b, c} ? – Dr. belisarius Oct 19 '15 at 14:43
• – rhermans Oct 19 '15 at 14:48
• Yet another possible duplicate: mathematica.stackexchange.com/q/96074/12 – Szabolcs Oct 19 '15 at 14:53

BarChart[Counts[{"a", "a", "b", "c"}], ChartLabels -> Automatic] By using Counts instead of Tally, we get an Association that BarChart knows how to handle automatically.

Block[{t = Tally[{"a", "a", "b", "c"}]},
BarChart[t[[All, 2]], ChartLabels -> t[[All, 1]]
]] 