Reputation: 373
I have the following code that plots two pie charts one below the other. What I want is to plot them next to each other. How do I do that with the below information?
ax1=apr_prev.set_index('Previous').plot.pie(y='Previous_Counts', figsize=(8, 8), title="Top 10 Before", \
legend=False, autopct='%1.1f%%', shadow=True, startangle=0, explode=(0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0))
ax1.set_ylabel('')
ax2=apr_cur.set_index('Current').plot.pie(y='Current_Counts', figsize=(8, 8), title="Top 10 Current", \
legend=False, autopct='%1.1f%%', shadow=True, startangle=0, explode=(0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0))
ax2.set_ylabel('')
Upvotes: 0
Views: 953
Reputation: 5755
You need to:
Create 2 axes in the desired layout by:
fig, (ax1, ax2) = plt.subplots(1, 2)
Explictely state for each pie
, where to plot it by ax
param. For example:
apr_prev.set_index('Previous').plot.pie(y='Previous_Counts', figsize=(8, 8),
title="Top 10 Before", legend=False, autopct='%1.1f%%', shadow=True, startangle=0,
explode=(0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0), ax=ax1)
Upvotes: 1