2015-09-26 123 views
1

使用Seaborn 0.6.0如果我有一個熊貓DF看起來像這樣(只更長的時間):Seaborn:如何在圓形圖上繪製風速v方向?

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爲圓形網格,代表指南針方向和風速的光線發出從中心以速度代表射線的長度?

+0

我不知道是否有seaborn辦法做到風玫瑰,不過你沒看到http://matplotlib.org/examples/pie_and_polar_charts/polar_bar_demo.html? – areuexperienced

+0

這是一個matplotlib問題。 – mwaskom

回答

3

正如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