How to manage different labels in a bar chart, taking data from a text file?
<p>I'm new in using matplotlib, so I'm having some problems. I must create a bar chart with different labels, for each website that I have.
The file is like the following:</p>

<pre><code>1001 adblock 12
1001 badger 11
1001 disconnect 15
1001 ghostery 15
1001 nottrack 14
1001 origin 15
1001 policy 16
1001 ultimate 14
4ruote adblock 12
4ruote badger 1
4ruote disconnect 14
4ruote ghostery 27
4ruote nottrack 9
4ruote origin 26
4ruote policy 34
4ruote ultimate 20
...... ........ ...
</code></pre>

<p>My goal is to create a bar chart in which I have:</p>

<ol>
<li><p>on the x axis sites (first column of the file), is a string</p></li>
<li><p>on the y axis the values (third column of the file) for that site (that are 8 times repeated inside the file), so 8 integer values</p></li>
<li><p>labels that, for a specific site, are present in the second column (strings).</p></li>
</ol>

<p>I read different answers but each one didn't threat this comparison between labels, for a same variable.
What I'm doing is read the file, splitting the row and taking the first and third column, but how can I manage the labels?</p>

<p><code>seaborn</code> does this neatly:</p>

<pre><code>from pandas import read_csv
from matplotlib.pyplot import show
from seaborn import factorplot

fil = read_csv('multi_bar.txt', sep=r'\s*', engine='python', header=None)
fil.columns=['site','type','value']

factorplot(data=fil, x='site', y='value', hue='type', kind='bar')

show()
</code></pre>

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

python matplotlib