-
Notifications
You must be signed in to change notification settings - Fork 27
Add axes argument and return axes in plots #361
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
base: main
Are you sure you want to change the base?
Conversation
oops need to fix some things for tests |
Fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good; I think just needs some doc tweaks
@@ -286,21 +289,22 @@ def _plot_bubble(ax: axes.Axes, data: gpd.GeoDataFrame, geo_type: str, **kwargs: | |||
ax.legend(frameon=False, ncol=8, loc="lower center", bbox_to_anchor=(0.5, -0.1)) | |||
|
|||
|
|||
def _plot_background_states(figsize: tuple) -> tuple: | |||
def _plot_background_states(figsize: tuple, ax: axes.Axes = None) -> axes.Axes: | |||
"""Plot US states in light grey as the background for other plots. | |||
|
|||
:param figsize: Dimensions of plot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So figsize is ignored if axes are provided? Should it also be optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@@ -79,7 +80,8 @@ def plot(data: pd.DataFrame, | |||
Defaults to `True`. | |||
:param kwargs: Optional keyword arguments passed to ``GeoDataFrame.plot()``. | |||
:param plot_type: Type of plot to create. Either choropleth (default) or bubble map. | |||
:return: Matplotlib figure object. | |||
:param ax: Optional matplotlib axis to plot on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the docstring should say what happens if ax
is not provided (axes are made, states are plotted). Maybe that goes in the text above, such as in a paragraph after the one-line summary explaining that the maps are plotted on US states by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I had a bug here, the background states are always plotted and I had left that statement out. I've also added a sentence describing the return behavior.
|
||
|
||
def plot_choropleth(data: pd.DataFrame, | ||
time_value: date = None, | ||
combine_megacounties: bool = True, | ||
**kwargs: Any) -> figure.Figure: | ||
**kwargs: Any) -> axes.Axes: | ||
"""Plot choropleths for a signal. This method is deprecated and has been generalized to plot(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to use the deprecated directive here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added. This also made me realize our changelog is a bit incorrect, will make another PR to fix that.
running into some weird bugs with subplots, working through it now |
Fixed, was an axes limit issue |
This looks like a backwards-compatible change. Should we fix and merge or close? @capnrefsmmat |
Hmm, if this code still works, we might as well merge it. I don't think it's worth developing new features for the package in the long run, but since Andrew already did the hard work here, we might as well use it. Are you able to test this branch and see if it still works? We'd have to fix the merge conflicts in the tests as well. |
Closes #359
Summary of changes: