Online visitors

People learning around the world

Online

—

Active in the last 10 minutes

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    Python Program to Create Pie Charts Using Matplotlib

    Python Programming Examples


    This Python program contains a simple program to generate pie charts using the Matplotlib Python library. Matplotlib Python has an extensive library for creating stable, animated, and interactive data visualizations.

    In this Python program, we have used the popularity data of different programming languages and displayed it as a pie chart using the Matplotlib Python library.

    Example:

    An example of a Python Matplotlib Pie Chart:

    import matplotlib.pyplot as pyplot
    
    # Manual data setup
    labels = ('Python', 'Java', 'JavaScript', 'C#', 'PHP', 'C,C++', 'R')
    sizes = [29.9, 19.1, 8.2, 7.3, 6.2, 5.9, 3.7]
    
    # bar chart setup
    pyplot.pie(sizes, labels=labels, autopct='%1.f%%', counterclock=False, startangle=105)
    
    # layout configuration
    pyplot.ylabel('Usage in %')
    pyplot.xlabel('Programming Languages')
    
    # Save the chart file
    #pyplot.savefig('matplotlib_pie_chart01.png', dpi=300)
    
    # Print the chart
    pyplot.show()

    Program Output:

    Install Matplotlib

    The Matplotlib Python library is installed using pip (package manager for Python). The following command installs the Matplotlib package:

    pip install matplotlib



    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.

    Test browser code

    Use this code in admin to send a test notification to this browser.