pandas pie chart plot remove the label text on the wedge
Using pandas you can still use the matplotlib.pyplot.pie keyword labeldistance
to remove the wedge labels.
eg. df.plot.pie(subplots=True, labeldistance=None, legend=True)
From the docs:labeldistance
: float
or None
, optional, default: 1.1
The radial distance at which the pie labels are drawn. If set to None
, label are not drawn, but are stored for use in legend()
In context:
import matplotlib.pyplot as plt
plt.style.use('ggplot')
import numpy as np
np.random.seed(123456)
import pandas as pd
df = pd.DataFrame(3 * np.random.rand(4, 2), index=['a', 'b', 'c', 'd'], columns=['x', 'y'])
df.plot.pie(subplots=True, figsize=(10,5), autopct='%.2f', fontsize=10, labeldistance=None);
plt.show()
Output:
You can turn off the labels in the chart, and then define them within the call to legend
:
df[col].plot(kind='pie', autopct='%.2f', labels=['','','',''], ax=ax, title=col, fontsize=10)
ax.legend(loc=3, labels=df.index)
or
... labels=None ...