Having the following code i can't understand why is not showing correctly the information (check the column C and F) bot are show as the same value but are different
What i need is plot some of the columns in the df and share the legend between all subplots (all columns have the same values ["SI","NO"] (this is just a sample code )
colnames=['a','b','c','d','e','f','g']
values=[
['SI','SI','NO','SI','SI','SI','NO'],
['SI','NO','NO','SI','NO','SI','NO'],
['SI','SI','NO','SI','SI','SI','NO'],
['SI','NO','NO','NO','NO','SI','SI'],
['SI','NO','NO','NO','NO','SI','NO']]
df=pd.DataFrame(values, columns=colnames)
def pieplotstest(df):
fig,ax =plt.subplots(2,3,facecolor=(1, 1, 1),figsize=(7.2,4.3))
plt.style.use('fivethirtyeight')
colors=["#172a3d","#e33e31"]
textprops=dict(color="w",weight='bold',size=5)
labels=['NO','SI']
ax[0,0].pie(df['b'].value_counts(),
colors=colors,
autopct = '%1.1f%%',
textprops=textprops,
wedgeprops=dict(width=0.5),
pctdistance=0.7
)
ax[0,1].pie(df['c'].value_counts(),
colors=colors,
autopct = '%1.1f%%',
textprops=textprops,
wedgeprops=dict(width=0.5),
pctdistance=0.75
)
ax[0,2].pie(df['d'].value_counts(),
colors=colors,
autopct = '%1.1f%%',
textprops=textprops,
wedgeprops=dict(width=0.5),
pctdistance=0.75
)
ax[1,0].pie(df['e'].value_counts(),
colors=colors,
autopct = '%1.1f%%',
textprops=textprops,
wedgeprops=dict(width=0.5),
pctdistance=0.75
)
ax[1,1].pie(df['f'].value_counts(),
colors=colors,
autopct = '%1.1f%%',
textprops=textprops,
wedgeprops=dict(width=0.5),
pctdistance=0.75
)
ax[1,2].pie(df['g'].value_counts(),
colors=colors,
autopct = '%1.1f%%',
textprops=textprops,
wedgeprops=dict(width=0.5),
pctdistance=0.75
)
ax[0,0].set_title('b',fontsize=10)
ax[0,1].set_title('c',fontsize=10)
ax[0,2].set_title('d',fontsize=10)
ax[1,0].set_title('e',fontsize=10)
ax[1,1].set_title('f',fontsize=10)
ax[1,2].set_title('g',fontsize=10)
fig.legend(labels,
loc=4,
fontsize=7
)
plt.suptitle('Como estan distribuidas tus ventas')
fig.tight_layout()
plt.savefig(f'orders3.png',dpi=600,transparent=True)


