代码示例:
from matplotlib import pyplot as plt
x = range(1,10) #x轴的位置
y = [6,7,12,12,15,17,15,20,18] #y轴的位置
#传入x,y,通过plot画图,并设置折线颜色、透明度、折线样式和折线宽度 标记点、标记点大小、标记点边颜色、标记点边宽
plt.plot(x,y,color='red',alpha=0.3,linestyle='--',linewidth=5,marker='o'
,markeredgecolor='r',markersize='20',markeredgewidth=10)
plt.show()
效果截图:

标记类型:
| marker | symbol | description |
|---|---|---|
"." | ![]() | point |
"," | ![]() | pixel |
"o" | ![]() | circle |
"v" | ![]() | triangle_down |
"^" | ![]() | triangle_up |
"<" | ![]() | triangle_left |
">" | ![]() | triangle_right |
"1" | ![]() | tri_down |
"2" | ![]() | tri_up |
"3" | ![]() | tri_left |
"4" | ![]() | tri_right |
"8" | ![]() | octagon |
"s" | ![]() | square |
"p" | ![]() | pentagon |
"P" | ![]() | plus (filled) |
"*" | ![]() | star |
"h" | ![]() | hexagon1 |
"H" | ![]() | hexagon2 |
"+" | ![]() | plus |
"x" | ![]() | x |
"X" | ![]() | x (filled) |
"D" | ![]() | diamond |
"d" | ![]() | thin_diamond |
"|" | ![]() | vline |
"_" | ![]() | hline |
0 (TICKLEFT) | ![]() | tickleft |
1 (TICKRIGHT) | ![]() | tickright |
2 (TICKUP) | ![]() | tickup |
3 (TICKDOWN) | ![]() | tickdown |
4 (CARETLEFT) | ![]() | caretleft |
5 (CARETRIGHT) | ![]() | caretright |
6 (CARETUP) | ![]() | caretup |
7 (CARETDOWN) | ![]() | caretdown |
8 (CARETLEFTBASE) | ![]() | caretleft (centered at base) |
9 (CARETRIGHTBASE) | ![]() | caretright (centered at base) |
10 (CARETUPBASE) | ![]() | caretup (centered at base) |
11 (CARETDOWNBASE) | ![]() | caretdown (centered at base) |
"None", " " or "" | nothing | |
'$...$' | ![]() | Render the string using mathtext. E.g "$f$" for marker showing the letter f. |
verts | A list of (x, y) pairs used for Path vertices. The center of the marker is located at (0, 0) and the size is normalized, such that the created path is encapsulated inside the unit cell. | |
| path | A Path instance. | |
(numsides, 0, angle) | A regular polygon with numsides sides, rotated by angle. | |
(numsides, 1, angle) | A star-like symbol with numsides sides, rotated by angle. | |
(numsides, 2, angle) | An asterisk with numsides sides, rotated by angle. |
本文介绍使用Matplotlib绘制带有特定标记类型的图表的方法。通过实例展示了如何设置折线的颜色、透明度、样式等属性,并详细列举了各种可用的标记类型及其含义。






































1万+

被折叠的 条评论
为什么被折叠?



