首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windrose:散点图wrscatter contourf

Windrose:散点图wrscatter contourf
EN

Stack Overflow用户
提问于 2019-11-26 03:05:15
回答 1查看 212关注 0票数 0

我想将contourf()制作的风玫瑰覆盖在Wr散点图上。这是我的MWE:

代码语言:javascript
复制
import random
wind_dir = []; wind_speed = [];
for i in range(30):
    wind_dir.extend(random.sample(range(0, 359),1))
    wind_speed.extend(random.sample(range(0, 10),1))

import windrose
wd1 = np.radians([0, 45, 90, 135, 180, 225, 270, 315])
ws = [1.0, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95]
vf = np.vectorize(lambda wd: -wd + np.pi / 2)
wd = vf(wd1)

fig = plt.figure()
from windrose import WindroseAxes
plt.figure(figsize=(15,12))
ax = WindroseAxes.from_ax()
ax.contourf(wind_dir,wind_speed, bins=np.arange(0, 8, 1))
ax.set_legend()
windrose.wrscatter(wd, ws)
plt.legend(loc='center left', bbox_to_anchor=(1, 0.5),prop={'size': 20})
plt.show()

现在这两个地块是分开的,但我希望将它们重叠在一个地块中。感谢您的帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-26 04:59:17

如果您将相同的轴添加到wrscatter,它们将使用相同的绘图。

代码语言:javascript
复制
import numpy as np
from matplotlib import pyplot as plt
import windrose

wind_dir = np.random.uniform(0, 360, 50)
wind_speed = np.random.uniform(0, 11, 50)

wd1 = np.radians([0, 45, 90, 135, 180, 225, 270, 315])
ws = [1.0, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95]
vf = np.vectorize(lambda wd: -wd + np.pi / 2)
wd = vf(wd1)

ax = windrose.WindroseAxes.from_ax()
ax.contourf(wind_dir, wind_speed, bins=np.arange(0, 8, 1))
ax.set_legend()
windrose.wrscatter(wd, ws, ax=ax)
plt.legend(loc='center left', bbox_to_anchor=(1, 0.5), prop={'size': 20})
plt.show()

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59038547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档