3
$\begingroup$

I have a nested list of the form

list= {{1,1,1},{1,2,3},{1,1,1}}

How can I plot a histogram that tells me how often each number pattern appears in my list?

For example, {1,1,1} occurs two times and {1,2,3} occurs one time etc.

$\endgroup$
1
  • $\begingroup$ A histogram needs an order imposed over the x axis $\endgroup$ Commented Apr 28, 2015 at 15:50

1 Answer 1

3
$\begingroup$

You can use Tally to count the occurrences of each element and use the result in BarChart :

list = {{1, 1, 1}, {1, 2, 3}, {1, 1, 1}};
BarChart[Labeled[#2, #1] & @@@ Tally[list]]

Mathematica graphics

Or, use BubbleChart3D with the bubble sizes representing the counts:

BubbleChart3D[Flatten /@ Tally[list]]

Mathematica graphics

$\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.