Search code examples
pythonpython-3.xmatplotlibpie-chart

pie chart doesn't show up without error python


I have a data frame like this: enter image description here

and I want to have a pie chart on it. I used these 2 ways for drawing a pie chart but they don't work!

fig6, ax6 = plt.subplots()
ax6.pie(df6, explode=None, labels=df6.index, autopct='%1.1f%%',
    shadow=False, startangle=90)
ax6.axis('equal') 
plt.ylabel('Twjkhjeet Class Popularity Vs. Day')


plt.show()

and

plt.figure(figsize=(5,5))
labels = 'Negative', 'Positive'
sizes = [9178, 2363]
colors = ['brown', 'lightblue']
explode = (0, 0) 
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
    autopct='%1.1f%%', shadow=True, startangle=140)
plt.axis('equal')
plt.show()

I dont receive any error from these codes but the plot doesn't show up!


Solution

  • I should have put %matplotlib inlinebefore the fig6, ax6 = plt.subplots(). This is how I could see the plot after running the code.