1 load matplotli The drawing module of , And rename to plt

`import matplotlib.pyplot as plt`

2 Broken line diagram

```import matplotlib.pyplot as plt
import numpy as np
x = np.arange(9)
y = np.sin(x)
z = np.cos(x)
# marker Data point style ,linewidth Line width ,linestyle Line style ,color Color
plt.plot(x, y, marker="*", linewidth=3, linestyle="--", color="orange")
plt.plot(x, z)
plt.title("y and z")
plt.xlabel("x")
plt.ylabel('height')
# Set legend
plt.legend(["y","z"], loc="upper right")
plt.grid(True)
plt.show()``` 3 Scatter plot

```x = np.random.rand(10)
y = np.random.rand(10)
plt.scatter(x,y)
plt.show()``` 4 Histogram

```x = np.arange(20)
y = np.random.randint(0,30,20)
plt.bar(x, y)
plt.show()``` 5 The pie chart

```x = np.random.randint(1,10,4)
plt.pie(x)
plt.show()``` 6 Histogram

```mean, sigma = 0, 1
x = mean + sigma*np.random.randn(1000) #randn To produce a normal distribution
plt.hist(x,50)
plt.show()``` 7 Subgraphs

`subplot(numRows, numCols, plotNum) # That's ok , Column , Area number `
```# figsize The width and height of the drawing object , In inches ,dpi The resolution of the drawing object , How many pixels per inch , The default value is 80
plt.figure(figsize=(8,6),dpi=100)
# subplot(numRows, numCols, plotNum)
# One Figure Objects can contain multiple subgraphs Axes,subplot Divide the whole drawing area into numRows That's ok *numCols List sub regions , From left to right , Each sub area is numbered from top to bottom
# subplot stay plotNum Create a subgraph in the specified area Axes
A = plt.subplot(2,2,1)
plt.plot([0,1],[0,1], color="red")
plt.subplot(2,2,2)
plt.title("B")
plt.plot([0,1],[0,1], color="green")
plt.subplot(2,1,2)
plt.title("C")
plt.plot(np.arange(10), np.random.rand(10), color="orange")
# Select the subgraph A
plt.sca(A)
plt.title("A")
plt.show()``` 8 Show Chinese in the picture

matplotlib Chinese cannot be displayed by default , You can modify the font directly in the program

```from matplotlib.font_manager import FontProperties
import matplotlib.pyplot as plt
import numpy as np
font = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=14)
t = np.linspace(0, 10, 1000)
y = np.sin(t)
plt.plot(t, y)
plt.xlabel(u" Time ", fontproperties=font)
plt.ylabel(u" The amplitude ", fontproperties=font)
plt.title(u" Sine wave ", fontproperties=font)
plt.show()``` ## Python expanded memory bank 2—matplotlib More articles about

1. window Next python Expansion library installation Use a third-party mirror source

0. Preface     because python The official image of is located abroad , If you use pip perhaps easy_install Installation of third-party plug-ins may be restricted , Even easy_install or pip Can't install , For example, in windows In the environment ...

2. 1.4.1 install Python expanded memory bank

Python The reason why we get engineers from various industries . Planners and managers , It also has a lot to do with the extended libraries developed in various industries and fields , Not only in large numbers . Powerful , The key is that it's easy to use . although Python The standard library already has very powerful functions ...

3. Python expanded memory bank 1—numpy

1 Array objects Create array import numpy as np a = np.arange(10) b = np.arange(2,10,1) #[2,10) In steps of 1 c = np.linspace ...

4. One has python Extension library download site

https://www.lfd.uci.edu/~gohlke/pythonlibs/

5. 『Python Question bank - Completion 』151 Avenue Python Fill in the blanks in the written test

『Python Question bank - Completion 』Python Fill in the blanks in the written test part 1. Python Language Overview and Python Development environment configuration part 2. Python The basic grammatical elements of language ( Variable , Basic data type ,  Basic operation ) ...

6. Python Question bank series share one （17 Avenue ）

1.1  To Python Download and install from the official website Python Interpreter environment .1.2  To Anaconda Download and install the latest Anaconda3 development environment .1.3  Python programmatic __name__ What is the role of ...

7. RF The shared use of variables and python Test library -5

RF Declare variables : First we need to create Variables surface *** Settings *** \${LoginUrl}      http://cloud.innovpowerf.com/Account/Log ...

8. Python Advanced modules 、 Standard library 、 expanded memory bank

Advanced modules Python There's a very useful library of standards (standard library). Standard library will follow Python Interpreter , Installed in your computer together . It is Python An integral part of . These standard libraries are Python It's up to you ...

9. Python Environmental Science —— Install extension library

One . modify easy_install Source Add a file to the user's home directory cat >> ~/.pydistutils.cfg <<EOF [easy_install] index-ur ...

## Random recommendation

1. JAVA File download function problem solving log

Today, I made a download function for the report system , A lot of problems , We solved the problem one by one by looking up the data . 1. The first problem is :java After the background output stream is output , There is no mistake , The browser side does not pop up the dialog box to save the file , It was ajax Request to backstage con ...

2. MySQL Underline special characters (Like sentence )

Recently used MySQL+ibatis  Do the project Problem description : stay SQL in Yes a.name like ##%searchName%## searchName=test_1 The result of the discovery : test_1, ...

3. CORDIC Principle and FPGA Realization （2）

CORDIC The algorithm implements polar coordinates (polar) To rectangular coordinates (Cartesian) Transformation of . 1: function [horizonal,vertical]=polar2car(mag, pha); 2: x ...

4. Half Moon Serenade under the imagination --DOCTYPE Pattern

Half Moon Serenade under the imagination --DOCTYPE Pattern @(css3 box-sizing)[doctype Statement |quirks Pattern | Miao Tong ] DOCTYPE Document type label , The tag is a specific standard common markup language or XML file ...

5. Html Code Font-Size in px And pt The difference between

One is equipment coordinates , One is logical coordinates , The two are different . px It's a relative unit , The reference value of general pixel is : In a pixel density is 90 pdi On the , Normal people from the distance display 28 The viewing angle of a pixel in inches should not be less than 0.0227 degree . 1 ...

6. （ Reprint ）LINUX UNBUNTU10.04 Next build OC Compile environment

( Reprint )http://blog.sina.com.cn/s/blog_833996210100rgl4.html 1 install / install GNUstep on ubuntu The packages listed below are installation G ...

7. What you don't know css Selectors

The selectors we're dealing with right now :.class   #id  div  ...... I don't know about selectors :a>b   a+b [a~=b] [a|=b]......   Let's talk about it 5 6 7 8 by css3 It's a decision in the book ...

8. compile ORB_SLAM2 （ One ）

There were records about ORB_SLAM Compilation of the first version of , Every time you compile the program , There are a lot of problems , It's not so-called that you can compile successfully according to the tutorial , So this compilation also encountered a lot of problems . Baidu also saw many similar problems on the Internet , but ...

9. Distributed Advanced ( 11、 ... and ) Docker Summary of common errors

NO.1 The above command to add a bridge is in Ubuntu14.04 It's not feasible . The correct order is as follows : brctl addbr br0 ifconfig br0 192.168.1.188 netmask 255.255 ...

10. Python Conduct JSON Format output , And the display of Chinese characters

Format output Reprinted address   https://blog.csdn.net/real_tino/article/details/76422634 Problem analysis : Python Next json Manipulative json In print view , ...