windrose:__ init __()得到关键字参数的多个值

时间:2016-01-13 18:17:06

标签: python python-2.7 matplotlib

我知道这不是一个新问题,但我尝试使用我看到的博客中的信息所做的一切并不适合我。我试着为windrose运行这个例子:

from windrose import WindroseAxes
from matplotlib import pyplot as plt
import matplotlib.cm as cm
import numpy as np
import imp

ws = np.random.random(500) * 6
wd = np.random.random(500) * 360

ax = WindroseAxes.from_ax()
ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')
ax.set_legend()

ax = WindroseAxes.from_ax()
ax.contourf(wd, ws, bins=np.arange(0, 8, 1), cmap=cm.hot)
ax.set_legend()

ax.bar(wd, ws, normed=True, nsector=16)
table = ax._info['table']
wd_freq = np.sum(table, axis=0)

direction = ax._info['dir']
wd_freq = np.sum(table, axis=0)
plt.bar(np.arange(16), wd_freq, align='center')

但我只得到这个追溯:

Traceback (most recent call last):
  File "/home/user/Documents/the_windrose.py", line 31, in <module>
    plt.bar(np.arange(16), wd_freq, align='center')
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 2643, in bar
**kwargs)
  File "/home/user/.local/lib/python2.7/site-packages/windrose/windrose.py", line 390, in bar
**kwargs)
TypeError: __init__() got multiple values for keyword argument 'width'

我不明白这个问题。这里有什么问题?

1 个答案:

答案 0 :(得分:0)

问题解决了!如果你仔细看看代码的作用,这很简单。我犯了一个错误,就是我在ax.bar(...)ax.contourf(...)的行中看到了两次绘制轴。通过运行python每次尝试绘制这两个轴并得到多个值的错误。