windrose icon indicating copy to clipboard operation
windrose copied to clipboard

windrose plot sectors show straight line instead of curved ones

Open yngwaz opened this issue 4 years ago • 1 comments

Following the minimal example of https://windrose.readthedocs.io/en/latest/usage.html#script-example I obtain a windrose plot which shows a straight line for each sector (instead of a curved one).

Figure_1

Same happens for more elaborate examples. However, following the sample script for a polar bar chart from matplotlib: https://matplotlib.org/3.2.1/gallery/pie_and_polar_charts/polar_bar.html#sphx-glr-gallery-pie-and-polar-charts-polar-bar-py I do get the rounded/curved sectors.

I am using: windrose 1.6.7 pypi_0 pypi python 3.8.5 h425cb1d_1_cpython conda-forge matplotlib-base 3.3.0 py38h91b0d89_1 conda-forge

Any ideas why this is happening? Many thanks!

yngwaz avatar Aug 04 '20 08:08 yngwaz

The workaround for this issue (found by my colleague at work) is as follows:

fig = plt.figure()
rect = [0.1, 0.1, 0.8, 0.8]
hist_ax = plt.Axes(fig,rect)
hist_ax.bar(np.array([1]), np.array([1]))
# only after creating the dummy axes above, the windrose will plot curved sectors!

ax = WindroseAxes.from_ax()   

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

wr_plot

yngwaz avatar Aug 04 '20 10:08 yngwaz

Closing this as answered. Please re-open if you disagree.

ocefpaf avatar Sep 21 '22 18:09 ocefpaf

Mhm, I'm running into the same issue while writing tests using a baseline image and comparing results to it. I got random fails and was wondering why this was the case.

Turns out if the tests runs first, the sectors will have square ends, if it runs after any other test that involves plotting, it succeeds.

So for some reason we need to run some plotting before, so it gets the rounded results -- I have no idea how to debug this though. Something is different with either the object or the global state.

Since this causes inconsistent behavior, I'd consider this a bug we should address or at least find out what's going on...

I'll dig deeper into this and let you know if I come across anything...

jkittner avatar Apr 15 '24 18:04 jkittner

@yngwaz - I created #266 that fixes the issue for me. Maybe you can try if that also works for you, and you can remove your workaround?

jkittner avatar Apr 21 '24 22:04 jkittner