John Rumpel
John Rumpel

Reputation: 4615

matplotlib: print histogram based upon multi-dimensional dictionary data

it's my first time using python. I want to plot a histogram based on a simple data set stored in a dictionary as follows:

x = {'2010': [2,555,11], '2011': [1, 777, 12], ...}

as you can see, there would be three data values each bin.

It's easy to make a plot based on only one data, but how to handle this case?

Thanks a lot

Upvotes: 0

Views: 2390

Answers (1)

Developer
Developer

Reputation: 8400

n, bins, patches = pylab.hist(x, 10, normed=1, histtype='bar', stacked=True)

Follow the example given in this {matplotlib example page}, it is very helpful.

enter image description here


Simple Example:

import numpy as np
import pylab as pl
x = np.random.rand(100,3)
pl.hist(x,stacked=True)
pl.show()

enter image description here

Upvotes: 1

Related Questions