Search code examples
pythonmatplotlibplotdata-visualizationpie-chart

How plot Pie_chart in python while having 3 columns of data


Charging Number Share
0-20%. 9. 15.50%
21-40%. 18. 31%.
41-60%. 4. 6.90%
61-80%. 9. 15.50%
81-100% 8. 13.80%
>100% 10. 17.30%

Solution

  • You can use pie() function from pyplot to draw pie charts in python. First you need to install matplotlib:

    pip install matplotlib
    

    Then you can create pie charts by providing the sizes and labels:

    import matplotlib.pyplot as plt
    
    labels = 'Charging', 'Number', 'Share'
    sizes = [20, 9, 15.5]
    
    fig1, ax1 = plt.subplots()
    ax1.pie(sizes, labels=labels, startangle=90)
    ax1.axis('equal')
    
    plt.show()
    

    Pie chart documentation: pyplot-pie