简体   繁体   中英

Labels in table of visualization of Pandas

​ ​Hi, I am plotting a Pandas dataframe. The Pandas Dataframe look like this:

;Cosine;Neutralized
author;0.842075;0.641600
genre;0.839696;0.903227
author+genre;0.833966;0.681121

And the code for plotting that I am using is:

fig = ari_total.plot(kind="bar", legend = False, colormap= "summer",
                     figsize= ([7,6]), title = "Homogeinity "+corpora+" (texts: "+str(amount_texts)+")", table=True,
                    use_index=False, ylim =[0,1]).get_figure()

The result is nice, but it has a problem: 在此处输入图片说明

As you can see, the labs from the index of the table "author", "genre" and "author+gender" are render over 0, 1 and 2.

My question: how can I delete this numbers and still using the same function? I am using the argument use_index=False, which I thought they would delete the labels from the bars, but it actually only replace them with this numbers...

I would be very thankfull if you could help. Regards!

Use fig.axes[0].get_xaxis().set_visible(False) .

code:

import pandas as pd
import matplotlib.pyplot as plt

df = pd.DataFrame()
df['Cosine'] = [0.842075,0.839696,0.833966]
df['Neutralized'] = [0.641600,0.903227,0.681121]
df.index = ['author', 'genre', 'author+genre']
fig = df.plot(kind="bar", legend = False, colormap= "summer",
                     figsize= ([7,6]), title = "whatever", table=True,
                    use_index=False, ylim =[0,1]).get_figure()
fig.axes[0].get_xaxis().set_visible(False)
plt.show()

result:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM