Research breakthrough possible @S-Logix pro@slogix.in

Office Address

Social List

How to Visualize Data Using Pie Chart

Pie Chart in Python

Condition for Visualizing Data Using Pie Chart in Python

  • Description:
    A pie chart is a circular statistical graphic divided into slices to illustrate numerical proportions. It is commonly used to show percentage or proportional data, with the entire circle representing 100%.
Step-by-Step Process
  • Import Required Libraries:
    Import the necessary libraries, typically matplotlib.pyplot.
  • Prepare Data:
    Define the data to be visualized. This includes the values and labels for each category.
  • Create the Pie Chart:
    Use the pie() function from Matplotlib to generate the chart.
  • Customize (Optional):
    Add enhancements like a title, labels, a legend, or even exploding specific slices for emphasis.
  • Display the Chart:
    Use plt.show() to display the pie chart.
Sample Source Code
  • # Pie-Chart

    import matplotlib.pyplot as plt

    labels=['Python','Java','C++','JavaScript']
    sizes=[40,30,20,10]
    colors=['gold','red','lightcoral','lightskyblue']
    explode=(0.1,0,0,0)

    plt.figure(figsize=(7, 7))
    plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=140)

    plt.title('Programming Language Popularity')

    plt.show()
Screenshots
  • Pie Chart Output