matplotlib Axes.scatter 函数学习笔记

本文介绍了matplotlib库中Axes.scatter函数的用法,包括设置点的大小、颜色、形状及透明度等属性,并通过示例展示了不同参数的效果,帮助理解scatter函数在绘制散点图时的灵活性。
摘要由CSDN通过智能技术生成

函数头:

def Axes.scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, **kwargs)

返回:: PathCollection

要求:x,y必须是相同长度序列

RewrappedMake a scatter plot of x vs y, where x and y are sequence like objects of the same lengths.



Parameters(参数)

----------

x,y:输入组,类似数组

x, y : array_like, shape (n, )

    Input data

实验:画三个点

fig1 = plt.figure(num='fig1',figsize=(6,3),dpi=75,facecolor='#FFFFFF',edgecolor='#FF0000')
plt.xlim(0,20)
plt.ylim(0,10)

x = [2,4,6]
y = [2,2,2]
plt.scatter(x,y)

plt.show()
plt.close()


s:点的大小(面积),标量或数组,缺省值为 (20*20)

s : scalar or array_like, shape (n, ), optional, default: 20

    size in points^2.

实验:

x = [2,4,6,8,10,14,18]
y = [2,2,2,2,2,2,2]
s = []
for i in x:
  s.append(i*i)
plt.scatter(x,y,s=s)

运行结果 :


注意:s实际显示的最小尺寸受到linewidth的影响


c:颜色

c : color or sequence of color, optional, default : 'b'
    `c` can be a single color format string, or a sequence of color
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值