-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Replace subplot(ijk) calls by subplots(i, j) #18567
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
Conversation
f87338c
to
14407d8
Compare
@@ -602,26 +602,21 @@ def test_fill_units(): | |||
dt = np.arange('2009-04-27', '2009-04-29', dtype='datetime64[D]') | |||
dtn = mdates.date2num(dt) | |||
|
|||
fig = plt.figure() | |||
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2) |
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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @tacaswell, especially since this minimizes changes.
@@ -602,26 +602,21 @@ def test_fill_units(): | |||
dt = np.arange('2009-04-27', '2009-04-29', dtype='datetime64[D]') | |||
dtn = mdates.date2num(dt) | |||
|
|||
fig = plt.figure() | |||
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2) |
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 agree with @tacaswell, especially since this minimizes changes.
PR Summary
Addresses part of the cases of #17335.
Plus some minor cleanup along the way.