Responsive Navbar with Google Search
☰ Menu
Home
Python
LaTeX
GNUPlot
Arduino
Feedback
Contact Us
Plotting in Python: Pie Chart
Plotting in Python
Basic Plot and formatting
Subplot, Multiplot
Colormaps in Plots
Bar Plot
Pie Chart
Histogram
Quiver plot to show Vector Fields
Stream plot to Visualize Flow Data
Polar, Parametric Plot
Contour Plot
3D Plot
Density Plot
Animated Plot
Miscellaneous
Pie Chart: Program 1
Pie Chart with Exploded Slices
import matplotlib.pyplot as plt sizes = [25, 35, 20, 20] labels = ['A', 'B', 'C', 'D'] colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue'] explode = (0.1, 0, 0, 0) # explode 1st slice plt.pie(sizes, labels=labels, colors=colors, explode=explode, autopct='%1.1f%%', startangle=140) plt.title('Pie Chart with Exploded Slices') plt.savefig('pie_chart_2.png')
Run Code
Output 1
Pie Chart: Program 2
Pie Chart with Percentage Labels Only
import matplotlib.pyplot as plt sizes = [10, 20, 30, 40] labels = ['A', 'B', 'C', 'D'] colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue'] plt.pie(sizes, colors=colors, autopct='%1.1f%%', startangle=140) plt.title('Pie Chart with Percentage Labels Only') plt.savefig('pie_chart_4.png')
Run Code
Output 2