Python matplotlib.pyplot pie charts: how to remove shortcut on the left side?

I draw a piccher using piot.

import pylab import pandas as pd test = pd.Series(['male', 'male', 'male', 'male', 'female'], name="Sex") test = test.astype("category") groups = test.groupby([test]).agg(len) groups.plot(kind='pie', shadow=True) pylab.show() 

Result:

enter image description here

However, I cannot remove the shortcut on the left (marked in red in the picture). I have already tried

 plt.axes().set_xlabel('') 

and

 plt.axes().set_ylabel('') 

but it didn’t work.

+6
source share
1 answer

You can simply install ylabel by calling pylab.ylabel :

 pylab.ylabel('') 

or

 pylab.axes().set_ylabel('') 

In your example, plt.axes().set_ylabel('') will not work because you do not have import matplotlib.pyplot as plt in your code, so plt does not exist.

Alternatively, the groups.plot command returns an instance of Axes , so you can use it to install ylabel :

 ax=groups.plot(kind='pie', shadow=True) ax.set_ylabel('') 
+4
source

All Articles