【Matplotlib】数据点的标记样式

matplotlib.markers 中所有的标记

markersymboldescription
"."m00point
","m01pixel
"o"m02circle
"v"m03triangle_down
"^"m04triangle_up
"<"m05triangle_left
">"m06triangle_right
"1"m07tri_down
"2"m08tri_up
"3"m09tri_left
"4"m10tri_right
"8"m11octagon
"s"m12square
"p"m13pentagon
"P"m23plus (filled)
"*"m14star
"h"m15hexagon1
"H"m16hexagon2
"+"m17plus
"x"m18x
"X"m24x (filled)
"D"m19diamond
"d"m20thin_diamond
`""`m21
"_"m22hline
0 (TICKLEFT)m25tickleft
1 (TICKRIGHT)m26tickright
2 (TICKUP)m27tickup
3 (TICKDOWN)m28tickdown
4 (CARETLEFT)m29caretleft
5 (CARETRIGHT)m30caretright
6 (CARETUP)m31caretup
7 (CARETDOWN)m32caretdown
8 (CARETLEFTBASE)m33caretleft (centered at base)
9 (CARETRIGHTBASE)m34caretright (centered at base)
10 (CARETUPBASE)m35caretup (centered at base)
11 (CARETDOWNBASE)m36caretdown (centered at base)
"None", " " or ""nothing
'$...$'m37Render the string using mathtext. E.g "$f$" for marker showing the letter f.
vertsA 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.
pathA 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.

代码实例

1. 导入包

import matplotlib.pyplot as plt
import random

2. 生成随机数

random.seed(2022)
y = [random.gauss(0, 1) for i in range(10)]
x = range(10)
print(y)
# [-1.059911532796699, -0.21343209892227447, -0.13048724278481846, 0.3292493351854598, 
# 0.5945395388166395, -2.772070654427417, -1.2083544534018353, 0.7418635616787197, 
# 0.7416186001053393, -1.8432987685720519]

3. 画图

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(12, 6))

ax1.plot(x, y, marker='.', color='r') # marker='.'
ax2.plot(x, y, marker=',', color='g') # marker=','
ax3.plot(x, y, marker=',', color='b') # marker='1'
ax4.plot(x, y, marker='D', color='pink') # marker='D'

请添加图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值