Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: WindRose.plot() argument legend_kwargs are said to be passed to legend in the doc strings, but they are passed to colorbar instead #1023

Open
jaredthomas68 opened this issue Nov 8, 2024 · 1 comment

Comments

@jaredthomas68
Copy link
Collaborator

jaredthomas68 commented Nov 8, 2024

Bug report: WindRose.plot() argument legend_kwargs are said to be passed to legend in the doc strings, but they are passed to colorbar instead

WindRose.plot() argument legend_kwargs are said to be passed to legend in the doc strings, but they are passed to colorbar instead. This makes usage non-intuitive.

How to reproduce

Pass typical legend arguments to WindRose.plot()

    import matplotlib.pyplot as plt

    wind_data = fmodel.wind_data
  
    time_series = TimeSeries(
        wind_directions=wind_data.wind_directions,
        wind_speeds=wind_data.wind_speeds,
        turbulence_intensities=wind_data.turbulence_intensities,
    )
          
    wind_rose = time_series.to_WindRose(wd_edges=np.arange(0, 360, 3.0), ws_edges=np.arange(2, 20, 2.0))
      
    fig, ax = plt.subplots(1, figsize=(4,4), subplot_kw={'projection': 'polar'})

    ax = wind_rose.plot(ax=ax, wd_step=10, legend_kwargs={"title": "Wind Speed (m/s)", "frameon": True})

Relevant output

  File "floris/floris/wind_data.py", line 782, in plot
    ax.figure.colorbar(sm_ws, ax=ax, **legend_kwargs)
  File "matplotlib/figure.py", line 1253, in colorbar
    cb = cbar.Colorbar(cax, mappable, **{
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Floris version

4.2

System Information

  • OS: macOS 14.7.1
  • Python version: 3.11
  • Library versions
    • matplotlib: 3.9.2
@misi9170
Copy link
Collaborator

Hi @jaredthomas68 , thanks for raising this. I believe the problem was introduced in #969. I think you can get around this for now by setting legend_kwargs to {"label": Wind Speed (m/s)"} (and dropping the frameon argument). But this is a user-interface change that we should have handled more thoroughly in a minor release, so I'll look into a more robust bugfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants