I am new to Python and am attempting to create a wind rose using the windrose.py code found at this website: http://sourceforge.net/projects/windrose/
The following is the code I am running and I found the example code at the following website: 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)
When I run this code, I get the following error:
RuntimeWarning: invalid value encountered in rint
return round(decimals, out)
TypeError: __init__() got an unexpected keyword argument 'axespad'
Although I've tried a number of things I can't figure out what the axespad variable is doing in this code. Any advice would help!
Try changing this line:
to this:
Some background:
With my curiosity piqued, I decided to go on a bit of an adventure.
According to the matplotlib documentation,
axespadis not a valid argument to thelegendfunction, butborderaxespadis. I also noticed that the article you linked to was usingmatplotlib 0.98.3, which is a very outdated version (in fact, documentation isn't available for it anymore).Following my hunch I downloaded the old source from here, the new source from here, and compared the two.
Turns out that
matplotlib 0.98.3only has references toaxespadandmatplotlib 1.4.2only has references toborderaxespad. The code they are in is almost exactly the same. It looks like at some point they added border functionality toLegends and decided to rename the argument accordingly.