matplotlib.pyplot.scatter()函数用法

本文详细介绍了如何使用Matplotlib库中的scatter函数绘制散点图,包括参数x、y的坐标设定,散点大小s,颜色c,形状marker的自定义选项,以及颜色映射cmap等高级设置。通过丰富的参数解释,帮助读者掌握散点图的定制化绘制技巧。
摘要由CSDN通过智能技术生成

参考地址:https://matplotlib.org/api/_as_gen/matplotlib.pyplot.scatter.html?highlight=scatter#matplotlib.pyplot.scatter

 

函数原型:matplotlib.pyplot.scatter(xys=Nonec=Nonemarker=Nonecmap=Nonenorm=Nonevmin=Nonevmax=Nonealpha=Nonelinewidths=Noneverts=Noneedgecolors=None*data=None**kwargs)

 

参数解释:x,y:数据坐标

     s:散点的大小

                  c:散点的颜色 如果输入int就会自动生成指定数量种类的颜色给散点显示 如c=3就会生成3种不同颜色的散点

                  marker:散点的形状,参数对应表如下:

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
"|"m21vline
"_"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.
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 Path instance.
(numsides, style, angle) 

The marker can also be a tuple (numsides, style, angle), which will create a custom, regular symbol.

numsides:
the number of sides
style:

the style of the regular symbol:

  • 0: a regular polygon
  • 1: a star-like symbol
  • 2: an asterisk
  • 3: a circle (numsides and angle is ignored); deprecated.
angle:
the angle of rotation of the symbol

    cmap:指定颜色映射

    norm,vmin,vmax..:都是亮度,外观相关设置详见顶部网址。

转载于:https://www.cnblogs.com/ZengWeiHao/p/9992269.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值