Simple histogram setup (tags, ticks, etc.) Matplotlib / pandas

I am new to matplotlib and I am trying to use it in pandas to build some simple diagrams. I have a DataFrame that contains two score and person labels derived from another DF.

df1 = DataFrame(df, columns=['score','person']) 

Producing this conclusion:

table output

I am trying to create a simple histogram to show each person in a different color, and this is what I still have:

 df1.plot(kind='bar', title='Ranking') 

bar chart

How can I set it up so that the diagram displays the names of people along the x axis with unique colors and removes the "frame" around the figure? How can I make this a horizontal bar graph?

Thanks in advance for your help.

+7
python matplotlib pandas
source share
2 answers

I think this will give you an idea:

 df = pd.DataFrame({'score':np.random.randn(6), 'person':[x*3 for x in list('ABCDEF')]}) ax = plt.subplot(111) df.score.plot(ax=ax, kind='barh', color=list('rgbkym'), title='ranking') ax.axis('off') for i, x in enumerate(df.person): ax.text(0, i + .5, x, ha='right', fontsize='large') 

for

  person score 0 AAA 1.79 1 BBB 0.31 2 CCC -0.52 3 DDD 1.59 4 EEE 0.59 5 FFF -1.03 

You'll get:

hbar

+9
source share

For more information, see the pd.DataFrame.plot() . You will also definitely want to read the chart with matplotlib as well as matplotlib docs .

Getting a horizontal bar chart is easy, just use `kind = 'barh'.

-2
source share

All Articles