Issue
I have a problem about showing pie graphs in 2 row and 2 column. They are listed in one column.
How can I fix the issue?
Here is my code snippets shown below.
plt.figure(figsize = (8,8))
ax1 = plt.subplot(2,2,1)
coursera_df_beginner["course_Certificate_type"].value_counts().plot(kind='pie',shadow=True, explode=(0.1, 0, 0), startangle=90,autopct='%1.1f%%', ax=ax1)
plt.title('Difficulty in Courses')
plt.ylabel("")
plt.figure(figsize = (8,8))
ax2 = plt.subplot(2,2,2)
coursera_df_intermediate["course_Certificate_type"].value_counts().plot(kind='pie',shadow=True, explode=(0.1, 0, 0), startangle=90,autopct='%1.1f%%', ax=ax2)
plt.title('Difficulty in Courses')
plt.ylabel("")
plt.figure(figsize = (8,8))
ax3 = plt.subplot(2,2,3)
coursera_df_mixed["course_Certificate_type"].value_counts().plot(kind='pie',shadow=True, explode=(0.1,), startangle=90,autopct='%1.1f%%', ax=ax3)
plt.title('Difficulty in Courses')
plt.ylabel("")
plt.figure(figsize = (8,8))
ax4 = plt.subplot(2,2,4)
coursera_df_advanced["course_Certificate_type"].value_counts().plot(kind='pie',shadow=True, explode=(0.1, 0), startangle=90,autopct='%1.1f%%', ax=ax4)
plt.title('Difficulty in Courses')
plt.ylabel("")
Solution
Here is my answer
f,a = plt.subplots(2,2,figsize=(8,8))
f.subplots_adjust(wspace = .8)
coursera_df_beginner["course_Certificate_type"].value_counts().plot(kind='pie',
shadow=True,
explode=(0.1, 0, 0),
startangle=90,
autopct='%1.1f%%', ax=a[0,0])
a[0,0].set_title('Beginner Course')
a[0,0].set_ylabel('');
coursera_df_intermediate["course_Certificate_type"].value_counts().plot(kind='pie',
shadow=True,
explode=(0.1, 0, 0),
startangle=90,
autopct='%1.1f%%', ax=a[0,1])
a[0,1].set_title('Intermediate Course')
a[0,1].set_ylabel('');
coursera_df_mixed["course_Certificate_type"].value_counts().plot(kind='pie',
shadow=True,
explode=(0.1,),
startangle=90,
autopct='%1.1f%%',
ax=a[1,0])
a[1,0].set_title('Mixed Course')
a[1,0].set_ylabel('');
coursera_df_advanced["course_Certificate_type"].value_counts().plot(kind='pie',
shadow=True,
explode=(0.1, 0),
startangle=90,
autopct='%1.1f%%',
ax=a[1,1])
a[1,1].set_title('Advanced Course')
a[1,1].set_ylabel('');
Answered By - Tony Brand Answer Checked By - Robin (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.