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

WIP: Add ax and figsize arg to plotting functions #121

Merged
merged 6 commits into from Sep 21, 2022

Conversation

petebachant
Copy link
Contributor

@petebachant petebachant commented Aug 6, 2019

The objective here is to make it easier to create subplots, e.g.,

fig, (ax1, ax2) = plt.subplots(ncols=2)
plot_windrose(df1, ax=ax1)
plot_windrose(df2, ax=ax2)

Not quite ready. The ax args don't work at the moment, but figsize does. Perhaps there should be a windrose.subplots function to return the appropriate axes objects and provide a similar API?

@ocefpaf
Copy link
Collaborator

ocefpaf commented Sep 21, 2022

Not quite ready. The ax args don't work at the moment, but figsize does. Perhaps there should be a windrose.subplots function to return the appropriate axes objects and provide a similar API?

You need to pass the projection like subplot_kw={"projection": "windrose"}. Here is a working example:

from windrose import plot_windrose
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

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

df1 = pd.DataFrame({"speed": ws, "direction": wd})
df2 = pd.DataFrame({"speed": ws, "direction": wd})
fig, (ax1, ax2) = plt.subplots(ncols=2, subplot_kw={"projection": "windrose"})

plot_windrose(df1, ax=ax1)
plot_windrose(df2, ax=ax2)

I rebased this to run against the latest test and I'll add a subplot test to avoid regressions.

@ocefpaf
Copy link
Collaborator

ocefpaf commented Sep 21, 2022

@scls19fr another one 😬

(Almost ready for the new release. I just want to check some issues and minor docs fixes.)

@scls19fr scls19fr merged commit 860fc9a into python-windrose:main Sep 21, 2022
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

Successfully merging this pull request may close these issues.

None yet

3 participants