Histogram in python from a list of dictionaries
<p>I have a list of dictionaries:</p>

<pre><code>list_of_dicts = [{'user':user1, 'yob':1984, 'saves':24, 'hidden':28},
{'user':user2, 'yob':1989, 'saves':7, 'hidden':51}, {...}, ...]
</code></pre>

<p>And I want to make a stacked histogram plot of saves and hidden on the y-axis and yob on the x-axis. So the histogram should bin by <strong>yob</strong> and sum the number of saves or hidden for each dictionary in the list. For example, if there are 3 dictionaries with the common yob 1998 with saves of 8, 19 and 4 then the total saves for yob 1998 should be 31 and the hist plot for saves should be 31 in height in 1998. So something like:</p>

<pre><code>plt.hist([list_of_dicts['yob']['saves'], list_of_dicts['yob']['hidden']],
bins=45, stacked=True)
plt.show()
</code></pre>

<p>Not sure on the syntax to do this or how to access the elements in the list correctly, could anyone help? Thanks
*Edit: I know you can't index a list using a string (list_of_dicts['yob']) but that is where I am stuck and asking the question.</p>