python画圆填色_python – 根据使用散射的变量绘制没有填充,颜色和大小的圆圈

我相信这两种方法都可以实现您的目标.首先绘制未填充的圆圈,然后使用相同的点绘制散点图.对于散点图,请将大小设置为0,但使用它来设置颜色条.

请考虑以下示例:

import numpy as np

from matplotlib import pyplot as plt

import matplotlib.cm as cm

%matplotlib inline

# generate some random data

npoints = 5

x = np.random.randn(npoints)

y = np.random.randn(npoints)

# make the size proportional to the distance from the origin

s = [0.1*np.linalg.norm([a, b]) for a, b in zip(x, y)]

s = [a / max(s) for a in s] # scale

# set color based on size

c = s

colors = [cm.jet(color) for color in c] # gets the RGBA values from a float

# create a new figure

plt.figure()

ax = plt.gca()

for a, b, color, size in zip(x, y, colors, s):

# plot circles using the RGBA colors

circle = plt.Circle((a, b), size, color=color, fill=False)

ax.add_artist(circle)

# you may need to adjust the lims based on your data

minxy = 1.5*min(min(x), min(y))

maxxy = 1.5*max(max(x), max(y))

plt.xlim([minxy, maxxy])

plt.ylim([minxy, maxxy])

ax.set_aspect(1.0) # make aspect ratio square

# plot the scatter plot

plt.scatter(x,y,s=0, c=c, cmap='jet', facecolors='none')

plt.grid()

plt.colorbar() # this works because of the scatter

plt.show()

我的一次跑步的示例情节:

WL2eR.png

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值