-
-
Notifications
You must be signed in to change notification settings - Fork 85
API: change add_basemap to not return the received ax object #92
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
API: change add_basemap to not return the received ax object #92
Conversation
Is there a reference on @tacaswell's suggestion? I thought returning a new axis (if the input
I definitely agree with the second point and see how the first may be ambiguous. However, choosing to return the result of the |
I have found this: pandas-dev/pandas#4020 (comment) (although I thought there was also a more recent discussion about it) The main difference with all the other ones you mention (pandas, geopandas, seaborn) is that they all can create an ax. While here, |
Mainly what I would like to avoid is that people write:
as re-assigning to ax is simply useless (but which we already started to do ourselves in the tests). We could also return nothing for now, which is the most conservative and keeps the option open for later to return an artist (if there is a good use case) or ax (if we would start creating one). |
As I see it, I can't think of a case where |
Since we would still have discussion about returning only image artist or both image and text artists (not sure what the recommended way is then, if your function adds multiple items to the ax ..), we could also leave it to "not returning the ax" (returning nothing) to avoid breaking code later if we decide to return an artist. |
Updated the PR to return nothing for now, so we can further discuss what to return exactly, and if needed start to actually return something in the future. |
I have made this suggestion is many places, including in the docs (https://matplotlib.org/tutorials/introductory/usage.html#coding-styles) |
This is a proposal to change the return value of
add_basemap
fromax
to the Image artist created by the function. Some reasoning (as it is a breaking change):ax
is useless (you already pass the ax objects, so you already have this object named) and also potentially confusing (is this a different ax than the one passed in?)You can get this eg by inspecting
ax.get_children()
, but that is always a bit tricky. Having it returned from the function is easier (and in 99% of the cases the user can simply ignore this return value anyway).ax.imshow
).(one question might be if we also want to return the Text artist from the attribution)