Check this code:
import matplotlib.pyplot as plt
import pandas as pd
data = {
'Região': ['NORTE', 'SUDESTE', 'NORDESTE', 'CENTRO OESTE', 'SUL'],
'PNT "Real" sobre mercado BT (%)': [52.75, 15.04, 12.82, 8.23, 8.04]
}
data = pd.DataFrame(data)
data.set_index('Região', inplace=True)
plt.rcParams["figure.autolayout"] = True
fig, ax = plt.subplots()
ax.patch.set_edgecolor('black')
ax.patch.set_linewidth(1)
ax.pie(data['PNT "Real" sobre mercado BT (%)'].values, textprops={'size': 'smaller'}, labels=data.index, autopct='%1.2f%%', wedgeprops={'edgecolor':'black'})
ax.axis('equal')
# fig.savefig('pnts_sobre_BT_Regioes.png', dpi=300)
plt.show()
I am getting this figure as result:
Why are the values in the figure different from the ondes in data?
>Solution :
Because your data do not add up to 100 %. The keyword autopct means that percentages are calculated with respect to the sum of your data.
