Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a non-numerical data, let say

data = Table[RandomChoice[{0.2, 0.3, 0.25, 0.15, 0.1} -> {"A", "B", "C", "D", "E"}], {500}];

and i want to make a histogram for this data. My solution so far

datanew = data;
label = Sort@DeleteDuplicates[data];
Do[datanew = ReplaceAll[datanew, label[[i]] -> i], {i, 1, Length[label]}]
Histogram[datanew, Ticks -> {None, Automatic}, ChartLabels -> {None, Placed[label, Below]}]

Is there any better way to do this? Thank you.

share|improve this question
Have you tried anything already? Please post code to show what you want and where you are stuck. – Yves Klett Oct 16 '13 at 13:52
up vote 5 down vote accepted
tallydata = SortBy[Tally[data], First];
BarChart[tallydata[[All, 2]], ChartLabels -> (tallydata[[All, 1]])]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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