Plot a graph in python using common values in dictionary
<p>How can I visually represent the common keys when a value is selected. I am creating a form where the user will select a value, say <code>'john'</code>. I want to plot  the common keys'a', 'b' and 'c'. Suggestions on how to approach this problem will be very helpful.</p>

<pre><code>d = {
'a': ['john', 'doe', 'jane'], 
'b': ['james', 'danny', 'john'], 
'C':['john', 'scott', 'jane'],
}
</code></pre>

<p>You can create a data frame from the dictionary:</p>

<pre><code>import pandas as pd
import matplotlib.pyplot as plt
plt.style.use('ggplot')

df = pd.DataFrame({
'a': ['john', 'doe', 'jane'], 
'b': ['james', 'danny', 'john'], 
'c':['john', 'scott', 'jane'],
})
</code></pre>

<p>Then you can simply plot <code>john</code> like this:</p>

<pre><code>df.apply(lambda x: (x == 'john').sum()).plot(kind='bar')
</code></pre>

<p><a href="http://i.stack.imgur.com/fEQR5.png" rel="nofollow"><img src="http://i.stack.imgur.com/fEQR5.png" alt="enter image description here"></a></p>

<p><em>Since the string <code>john</code> only occurs one time in each column, all the bars are the same length.</em> </p>

python pandas dictionary matplotlib plot