-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use sublots in examples #1598
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
Use sublots in examples #1598
Conversation
At the recent LBL Software Carpentry Workshop, it was pointed out that there's an inconsistency within our documentation for how to create new figures with subplots. Indeed, most examples were using the old way, something like: fig = plt.figure() ax = plt.subplot(111) # or plt.add_subplot(111) This patch changes a whole bunch of instances like the above to: fig, ax = plt.subplots() We should strive to have a minimal amount of constants in our code, especially unusual ones like `111`, which only make sense to Matlab refugees. I have left unchanged examples which were using axes keywords passed to subplot() and add_subplot(), since those end up transforming things like: figure() subplot(111, axisbg='w') to plt.subplots(subplot_kw=dict(axisbg='w')) which isn't necessarily better. I also did not touch most of the user_interfaces examples, since those did not involve using plt, but instead explicitly imported Figure, and used the OO approach on Figure instances. Also updated instaces where the old "import pylab as p" convention was used to use our standard "import matplotlib.pyplot as plt" I have also updated some, but not all uses of subplot(121) etc, but I'm a bit exhausted after doing all of these.
--------------------------- | ||
For the sake of brevity and clarity, most of the :ref:`examples | ||
<examples-index>` now use the newer :func:`~matplotlib.pyplot.subplots` | ||
, which creates a figure and one (or multiple) axes object(s) in one |
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.
comma shouldn't be line wrapped here
I haven't picked through this with a fine-toothed comb, but +1 in general. We should try to get this merged before the MEP12 work gets underway -- this is a good start to the example/gallery cleanup that is planned. |
@@ -24,13 +24,13 @@ class BlitQT(QObject): | |||
def __init__(self): | |||
QObject.__init__(self, None, "app") | |||
|
|||
self.ax = p.subplot(111) | |||
self.ax = plt.axes() |
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.
fig
isn't used anywhere? Is that why you didn't do the usual fig, ax = plt.subplots()
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.
yes, that's right, using axes was suggested by @pelson here. Though now that this is back against master, I will just change this to the new plt.subplot()
@dmcdougall I think the final word was that this should not go into |
Surely there is no way b34b6b7 caused that Python 3.2 Travis failure... |
yeah, the false positive rate for Travis is pretty frustrating :\ |
Sometimes |
I'm closing this because it is replaced by #2043. |
this is a rebase of #1462 against master, as discussed on that PR. I believe it is ready to merge