0.摘要
本文主要介绍使用matplotlib绘图过程中的线形管理。
1.标准线形
线形 | 符号 |
实线 | - |
短线 | -- |
点线 | -. |
虚线 | : |
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,10,100)
y1 = x
y2 = x + 1
y3 = x + 3
y4 = x + 4
plt.plot(x,y1,linestyle='-')
plt.plot(x,y2,linestyle='--')
plt.plot(x,y3,linestyle='-.')
plt.plot(x,y4,linestyle=':')
plt.show()
2.线标
为了更加明显区别线形,可以通过在线上添加标记。
标准线标:
符号 | 含义 |
. | point marker |
, | point marker |
o | circle marker |
v | triangle_down marker |
^ | triangle_up marker |
< | triangle_left marker |
> | triangle_right marker |
1 | tri_down marker |
2 | tri_up marker |
3 | tri_left marker |
4 | tri_right marker |
s | square marker |
p | pentagon marker |
* | star marker |
h | hexagon1 marker |
H | hexagon2 marker |
+ | plus marker |
x | x marker |
D | diamond marker |
d | thin_diamond marker |
| | vline marker |
- | hline marker |
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,10,10)
y1 = x
y2 = x + 1
y3 = x + 3
y4 = x + 4
plt.plot(x,y1,marker='o')
plt.plot(x,y2,marker='^')
plt.plot(x,y3,marker='1')
plt.plot(x,y4,marker='*')
plt.show()