Convert hold-related functions to attribute assignments.#328
Convert hold-related functions to attribute assignments.#328WeatherGod merged 2 commits intomatplotlib:masterfrom
Conversation
This is a minimal change so that the deprecation of "hold" in mpl 2.x won't trigger warnings in Basemap from routine plotting calls.
|
Refer to matplotlib/matplotlib#7516 in mpl. |
|
sorry, I missed this earlier this month. This makes sense to do, but perhaps we should be doing |
|
or True, None... whateer... |
|
@WeatherGod: good idea to future-proof. I think I have done that now. Maybe I should have used a context-manager, but oh, well. |
| h = kwargs.pop('hold', None) | ||
| if hasattr(ax, '_hold'): | ||
| self._tmp_hold = ax._hold | ||
| ax._hold = h |
There was a problem hiding this comment.
This assignment only happens if the axes already has a _hold attribute. So, this wouldn't work if someone was setting the hold initially.
There was a problem hiding this comment.
My thinking here is that presently (with 2.x), the _hold attribute is always present. It is set in the AxesBase initializer. Some time in the future it won't be, and at that point Basemap doesn't need to obey it, and shouldn't set it at all.
There was a problem hiding this comment.
ah, yeah, that does make sense then. And it prevents basemap from adding the attribute itself if it isn't there already.
| ax._hold = h | ||
|
|
||
| def _restore_hold(self, ax): | ||
| if hasattr(ax, '_hold'): |
There was a problem hiding this comment.
I would check for hasattr(self, '_tmp_hold') instead, and then del the attribute when done
This is a minimal change so that the deprecation of "hold"
in mpl 2.x won't trigger warnings in Basemap from routine
plotting calls.