current position:Home>Drawing pie chart in Python
Drawing pie chart in Python
2022-07-24 15:47:43【I am a little rice】
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
labels=[" waters ", " Barren land ", " Low vegetation ", " tree ", " Architecture ", " playing field ", " road "]
colors = ["#126bae","#b7ae8f","#8cc269","#41b349","#fa7e23","#feba07"]
X=dataSet.iloc[0][2:]
fig = plt.figure()
plt.title(" Geological proportion before earthquake ")
plt.pie(X,labels=labels,colors=colors, autopct='%1.2f%%',pctdistance=0.8) # Draw a pie chart ( data , The label corresponding to the data , Keep two decimal places for the percentage )
plt.savefig("start.png", dpi=300)
plt.show();
X The numerical :
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
labels=[" waters ", " Barren land ", " Low vegetation ", " tree ", " Architecture ", " playing field ", " road "]
colors = ["#126bae","#b7ae8f","#8cc269","#41b349","#fa7e23","#feba07"]
X=dataSet.iloc[3][2:]
fig = plt.figure()
plt.pie(X,labels=labels, colors=colors, autopct='%1.2f%%', pctdistance=0.8) # Draw a pie chart ( data , The label corresponding to the data , Keep two decimal places for the percentage )
plt.title(" Geological proportion after earthquake ")
plt.savefig("end.png", dpi=300)
plt.show();
copyright notice
author[I am a little rice],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/205/202207241543108911.html
The sidebar is recommended
- Chinese garbled code in sublime Text3 compiling and running c++/java/python program language [solved]
- On the problem of Python: using numerical loops for cumulative calculation
- Pandas knowledge points - detailed grouping function groupby
- There is no network in the LAN. Use pip to install python3 plug-in
- Python 0x80070659 system policy prohibits this installation
- Python list parity split
- Python visual data analysis 01. Python environment construction
- Python visual data analysis 02. Scrapy framework - enhanced test scrapy CSS
- Python visual data analysis 03, Jieba [word segmentation]
- Image processing with Python opencv
guess what you like
Python AI tutorial Hagrid gesture recognition image data set (tutorial includes source code)
Python function parameter type summary
Function parameter passing in Python
Use of Python lists
Python sends simple SMTP mail
Application of sets in python (intersection and difference subsets, etc.)
Excuse me, I have opened a python 3.6 runtime FC. Without moving anything, the test function is directly executed
Zero threshold for career change and 100% employment? A group of young people are chasing Python
Python identification verification code - Google recapture 4*4 verification code
Python identification verification code - Google recapture 3*3 verification code
Random recommended
- Using the expansion of arctangent function to calculate the value of PI in Python
- Python01 - variables and simple data types
- Python excel cell data processing
- Pandas reading excel time field
- Pandas reads excel fields that contain characters beginning with 0
- HTTPS experience: introduction and use of basic cryptography knowledge and python pycrypto Library
- Python+vue COVID-19 vaccination management system Django project source code introduction
- Python image to character painting, with source code
- It is convenient to realize matrix transpose and inversion by using Python's unpacking and pressing methods
- Python error: typeerror,'int'object is not Iterable
- Python function comments appear: expected an indented block
- Python basic syntax - functions
- R language book learning 04 "implementation of multivariate statistical analysis R and python"
- Python word frequency analysis
- Docker series 4 dockerfile creates Python image
- Detailed explanation of Python's groupby() function
- Python scripting test cases
- Pyperclip module of Python -- copy and paste artifact
- Detailed explanation of Python · print output function
- [Python web] the use of Python to connect to third-party database series redis and redis
- [Python web] Python connection to third-party database series using pymongo to connect mongodb
- [Ubuntu operation] upgrade the default version of Python to python3.8 in Ubuntu 18.04.5
- [Python web] Python connects to third-party database series using pymysql to MySQL
- Python graphics development Kivy small problems
- Python tool method 33 easily realizes the integration of multiple losses based on the lossfusion class
- Summary of Python automated test interview questions (I) (continuously updated)
- Python office software automation, 5 minutes to master openpyxl operation
- Python interview question - [bisection search] given a sorted array of non repeating integers and a target value, if the target is found, the index is returned.
- Python test development django-197.django-celery-beat scheduled task
- Play with Python tips [i for I in range()] + [or]
- [leetcode scribble Python] 15. Sum of three numbers
- [leetcode scribble Python] 16. The sum of the nearest three numbers
- Python38 failed to install jsonpath. Problem solving
- Python test development django-193. use the supervisor background to start the celery service (worker/beat)
- Python test development django-194.addcomments module generates MySQL table field comments
- Python test development django-196.python 3.8 + django2 + celery5.2.7 environment preparation
- Python test development django-195.django add favicon.ico Icon
- [leetcode scribble Python] 122. The best time to buy and sell stocks II
- Common methods of saving pictures in Python
- Python word frequency analysis