简体   繁体   English

熊猫可视化表中的标签

[英]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. 如您所见,表“ author”,“ genre”和“ author + gender”的索引中的实验在0、1和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... 我正在使用参数use_index = False,我以为他们会从条形图中删除标签,但实际上只用这个数字替换了它们。

I would be very thankfull if you could help. 如果您能帮助我,我将非常感激。 Regards! 问候!

Use fig.axes[0].get_xaxis().set_visible(False) . 使用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: 结果:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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