python设置散点图点的大小_python散点图区域大小比例轴长度

首先,标记的大小以点为单位,而不是以像素为单位 . 在排版中,the point是最小的度量单位,在matplotlib中对应于1/72英寸的固定长度 . 相反,像素的大小将根据图形dpi和大小而变化 .

其次, plt.scatter 中标记的大小与圆的直径有关,而与半径无关 .

因此,每个标记的点数大小应计算如下:

size_in_points = (2 * radius_in_pixels / fig_dpi * 72 points/inch)**2

此外,如下面的MWE所示,可以直接用matplotlib transformations计算标记半径的大小,而不必事先生成空图:

import numpy as np

import matplotlib.pyplot as plt

plt.close('all')

# Generate some data :

N = 25

x = np.random.rand(N) + 0.5

y = np.random.rand(N) + 0.5

r = np.random.rand(N)/10

# Plot the data :

fig = plt.figure(facecolor='white', figsize=(7, 7))

ax = fig.add_subplot(111, aspect='equal')

ax.grid(True)

scat = ax.scatter(x, y, s=0, alpha=0.5, clip_on=False)

ax.axis([0, 2, 0,

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值