José José - 1 year ago 93
Python Question

Labels in table of visualization of Pandas

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


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:
enter image description here

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!

Answer Source

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


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()


enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download