python plot 渐变颜色不显示_python – 补丁中的matplotlib颜色渐变?

这是使用Alex的帖子中的想法的功能示例

import matplotlib.pyplot as plt,numpy as np

def gauplot(centers, radiuses, xr=None, yr=None):

nx, ny = 1000.,1000.

xgrid, ygrid = np.mgrid[xr[0]:xr[1]:(xr[1]-xr[0])/nx,yr[0]:yr[1]:(yr[1]-yr[0])/ny]

im = xgrid*0 + np.nan

xs = np.array([np.nan])

ys = np.array([np.nan])

fis = np.concatenate((np.linspace(-np.pi,np.pi,100), [np.nan]) )

cmap = plt.cm.gray

cmap.set_bad('white')

thresh = 3

for curcen,currad in zip(centers,radiuses):

curim=(((xgrid-curcen[0])**2+(ygrid-curcen[1])**2)**.5)/currad*thresh

im[curim

xs = np.append(xs, curcen[0] + currad * np.cos(fis))

ys = np.append(ys, curcen[1] + currad * np.sin(fis))

plt.imshow(im.T, cmap=cmap, extent=xr+yr)

plt.plot(xs, ys, 'r-')

这是你跑步时得到的

gauplot([(0,0), (2,3), (5,1), (6, 7), (6.1, 6.1)], [.3,. 4, .5, 1, .4], [-1,10], [-1,10])

# centers of circles # radii of circles#

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值