forked from Snailclimb/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo2.py
More file actions
29 lines (23 loc) · 514 Bytes
/
demo2.py
File metadata and controls
29 lines (23 loc) · 514 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-
"""
figure的使用
"""
import matplotlib.pyplot as plt
import numpy as np
#
x = np.linspace(-1, 1, 50)
# figure 1
y1 = 2 * x + 1
plt.figure()
plt.plot(x, y1)
# figure 2
y2 = x**2
plt.figure()
plt.plot(x, y2)
# figure 3,指定figure的编号并指定figure的大小, 指定线的颜色, 宽度和类型
#一个坐标轴上画了两个图形
y2 = x**2
plt.figure(num = 5, figsize = (4, 4))
plt.plot(x, y1)
plt.plot(x, y2, color = 'red', linewidth = 1.0, linestyle = '--')
plt.show()