我是 Python 新手,正在尝试使用windrose.py
以下网站上的代码创建风玫瑰:http: //sourceforge.net/projects/windrose/
以下是我正在运行的代码,我在以下网站找到了示例代码:http: //youarealegend.blogspot.com/search/label/windrose
import numpy
from windrose import WindroseAxes
from matplotlib import pyplot as plt
import matplotlib.cm as cm
from numpy.random import random
from numpy import arange
import windrose as wr
import matplotlib.pyplot as mp
import windrose
#Create wind speed and direction variables
ws = random(500)*6
wd = random(500)*360
#A quick way to create new windrose axes...
def new_axes():
fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')
rect = [0.1, 0.1, 0.8, 0.8]
ax = WindroseAxes(fig, rect, axisbg='w')
fig.add_axes(ax)
return ax
#...and adjust the legend box
def set_legend(ax):
l = ax.legend(axespad=-0.10)
plt.setp(l.get_texts(), fontsize=8)
wr.wrcontourf(wd, ws)
当我运行此代码时,我收到以下错误:
RuntimeWarning: invalid value encountered in rint
return round(decimals, out)
TypeError: __init__() got an unexpected keyword argument 'axespad'
虽然我已经尝试了很多事情,但我无法弄清楚axespad变量在这段代码中做了什么。任何建议都会有所帮助!