python - 西伯恩 : how to plot wind speed v direction on circular plot?

标签 python matplotlib plot

如果我有一个看起来像这样的 pandas df(只是更长),则使用 Seaborn 0.6.0:

windSpeed  windBearing
15.37          165
17.49          161
16.41          154
15.54          164
17.38          162
17.80            0
17.36          181
17.35          181
15.96          175
15.86          157 

如何将 windBearing 绘制为圆形网格,表示罗盘方向,将 windSpeed 绘制为从中心发出的射线,速度由射线的长度表示?

最佳答案

正如 mwaskom 在评论中所说,这是直接的 matplotlib,而不是 Seaborn。像这样:

import pandas as pd
from matplotlib import pyplot as plt
from math import radians

ax = plt.subplot(111, polar=True)
ax.scatter(x=[radians(x) for x in df['windBearing'].values], y=df['windSpeed'].values)
ax.set_theta_zero_location('N')
ax.set_theta_direction(-1)

生成此图表:

enter image description here

像往常一样,预先导入 Seaborn 确实使图表更具吸引力;相同的代码将产生:

enter image description here

关于python - 西伯恩 : how to plot wind speed v direction on circular plot?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32793953/

相关文章:

python - Django 查询将参数传递到values()

matplotlib - 如何更改pylab窗口背景颜色?

javascript - float如何使用阈值并具有曲线?

python - 如何使用笛卡尔坐标在 matplotlib 中绘制球体?

python - 使用 matplotlib 绘制许多图形

python 如何分割http请求线?

python - 通过 ntlm 的 Pycurl ssl 连接

python - 如果不使用 Django 刷新页面,则无法使用提交按钮

python - 如何在 matplotlib 工具栏中设置鼠标坐标的大小?

python - 在 PyQt GUI 中嵌入和更新 matplotlib 图形时出现内存泄漏