Smooth plot
I have found some real dark magic. Your module plots roses as triangles emerging from center - with straight, blocky edges. However, if you add this code (i.e. any histogram with pyplot)
plt.hist([0, 1]); plt.close()
before executing your function (i.e. WindroseAxes), you get smooth curvy roses like here:
http://climate.ncsu.edu/windrose.php
This doesn't make any sense and I couldn't figure out why this works, but it does. Any idea on why this happens and if you can add this "feature" to your module?
Hello @georgebv ,
Please, could you provide sample data (or random data), full code and screenshots comparing these 2 behaviors ?
Kind regards
This is the regular rose plot (vanilla):
This is what happens when I add and remove a pyplot histogram before your function:

This is my code:
def rose_plot(df, **kwargs):
Plots rose of values *val* for directions *direction*
in dtaframe *df* and saves it to folder *savepath*.
Parameters
----------
df : pandas dataframe
Pandas dataframe with columns *val* and *direction*
val : string
Column name of values in dataframe *df* (i.e. 'Hs')
direction : string
Column name of directions in dataframe *df* (i.e. 'Dp)
valbins : int
Number or value bins (default = 6)
dirbins : int
Number of directional bins (default = 12)
savepath : string
Path to output folder (default = doesn't save) (i.e. 'C:\\folder')
savename : string
Name of file
startfromzero : bool
Indicates if plot starts from 0 (N) (default = False)
valbinsize : float
Set binsize to override *valbins* parameter (default = None, assigns bins automatically)
title : str
Plot title
direction = kwargs.get('direction', 'Dp')
val = kwargs.get('val', 'Hs')
valbins = kwargs.get('valbins', 6)
dirbins = kwargs.get('dirbins', 12)
savepath = kwargs.get('savepath', None)
savename = kwargs.get('savename', 'Rose')
title = kwargs.get('title', 'Rose')
legend = kwargs.get('legend', 'Value [unit]')
startfromzero = kwargs.get('startfromzero', False)
valbinsize = kwargs.get('valbinsize', None)
plt.hist([0, 1])
plt.close()
a = df[pd.notnull(df[val])]
a = a[pd.notnull(a[direction])]
if startfromzero:
a[direction] = a[direction].apply(lambda x: x - 0.5 * 360 / dirbins)
ax = windrose.WindroseAxes.from_ax()
if valbinsize is not None:
valbins = np.arange(0, a[val].max() + valbinsize, valbinsize)
ax.bar(
a[direction],
a[val],
normed=True,
opening=1,
edgecolor='black',
bins=valbins,
nsector=dirbins,
cmap=cm.jet,
startfromzero=startfromzero
)
ax.set_legend()
ax.legend(loc=(-0.12, 0.75), title=legend, fontsize=9)
ax.get_legend().get_title().set_fontsize('9')
plt.title(title, y=1.08, fontsize=16)
if savepath is not None:
plt.savefig(savepath + '\\' + savename + '.png')
plt.close()
Oh yes I see it now clearly!

is better than

Any idea @LionelR ?
PR is welcome!
Pinging @wanglongqi
@scls19fr Any idea about what is happening here? calling bar function also changes the behavior.
Sorry @wanglongqi I haven't been able to understand what is happening. Any help on this is welcome
@scls19fr I think this is a bug in upstream, i.e. matplotlib. Probably should fire an issue in matplotlib repository.
@janschulz if you have time, can you please check this bug? This bug is reproducible.
Maybe passing the transform parameter to the plots methods calls can solve this problem. See https://stackoverflow.com/questions/19827792/matplotlib-drawing-a-smooth-circle-in-a-polar-plot
Likely related, with matplotlib 2.0 and windrose 1.6 the contour example from the front page has straight lines on the contours, but round edges on the fill
