Replace subplot(ijk) calls by subplots(i, j)#18567
Replace subplot(ijk) calls by subplots(i, j)#18567dopplershift merged 1 commit intomatplotlib:masterfrom
Conversation
f87338c to
14407d8
Compare
| dtn = mdates.date2num(dt) | ||
|
|
||
| fig = plt.figure() | ||
| fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2) |
There was a problem hiding this comment.
I am not a fan of this idiom versus fig, axs = plt.subplots(2, 2). You lose the ability to iterate if you spell them all out like this.
There was a problem hiding this comment.
I think which is better depends on what you are doing (a grid of similar Axes or a grid of very different Axes).
In this case the code was previously using axN so this is the minimal touch to move away from add_subplot(XYZ).
There was a problem hiding this comment.
And I think it also depends on the names you use,
fig, (ax_hist, ax_map) = plt.subplots(2)seems much better that slicing into an array (which is similar to the argument of why subplot_mosaic returns a dict).
There was a problem hiding this comment.
I agree with @tacaswell, especially since this minimizes changes.
| dtn = mdates.date2num(dt) | ||
|
|
||
| fig = plt.figure() | ||
| fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2) |
There was a problem hiding this comment.
I agree with @tacaswell, especially since this minimizes changes.
PR Summary
Addresses part of the cases of #17335.
Plus some minor cleanup along the way.