Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

DOC improved subplots' docstring #7232

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

Merged
merged 6 commits into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DOC figure and pyplot's subplot docstring are now identical
  • Loading branch information
NelleV committed Oct 11, 2016
commit 20cd16a4f0fb9e2655c89b6bb8173e390ead3db6
74 changes: 38 additions & 36 deletions 74 lib/matplotlib/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,48 +1025,50 @@ def subplots(self, nrows=1, ncols=1, sharex=False, sharey=False,

Parameters
----------
nrows : int, default: 1
Number of rows of the subplot grid.

ncols : int, default: 1
Number of columns of the subplot grid.
nrows, ncols : int, default: 1
Number of rows/cols of the subplot grid.

sharex : {"none", "all", "row", "col"} or bool, default: False
If *False*, or "none", each subplot has its own X axis.

If *True*, or "all", all subplots will share an X axis, and the x
tick labels on all but the last row of plots will be invisible.

If "col", each subplot column will share an X axis, and the x
tick labels on all but the last row of plots will be invisible.

If "row", each subplot row will share an X axis.
- If True, the x-axis will be shared amongst all subplots.
- If False, no axis will be shared amongst subplots.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'no x-axis' to be consistent with the part about the kwarg sharey? (I think @efiring already spotted it in a previous version.)

- If a string must be one of "row", "col", "all", or "none".
- "all" has the same effect as True.
- "none" has the same effect as False.
- If "row", each subplot row will share a x-axis.
- If "col", each subplot column will share a x-axis.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Disclaimer: I am not a native English speaker)
In these 2 lines, shouldn't it be 'an x-axis' instead of 'a x-axis'?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say so.


Note that if the x-axis is shared across rows (sharex=True or
sharex="col"), then the x tick labels will only be display on
subplots of the bottom row.

sharey : {"none", "all", "row", "col"} or bool, default: False
If *False*, or "none", each subplot has its own Y axis.

If *True*, or "all", all subplots will share an Y axis, and the y
tick labels on all but the first column of plots will be invisible.

If "row", each subplot row will share an Y axis, and the y tick
labels on all but the first column of plots will be invisible.

If "col", each subplot column will share an Y axis.
- If True, the y-axis will be shared amongst all subplots.
- If False, no y-axis will be shared amongst subplots.
- If a string must be one of "row", "col", "all", or "none".
- "all" has the same effect as True.
- "none" has the same effect as False.
- If "row", each subplot row will share a y-axis.
- If "col", each subplot column will share a y-axis

Note that if the y-axis is shared across columns (sharey=False or
sharey="col"), 1 then the y tick labels will only be displayed on
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Shouldn't it be 'sharey=True' instead of 'sharey=False'?
  • Spurious '1' after the comma?

subplots of the first column.

squeeze : bool, default: True
If *True*, extra dimensions are squeezed out from the returned axes
array:

- if only one subplot is constructed (nrows=ncols=1), the resulting
single Axes object is returned as a scalar.

- for Nx1 or 1xN subplots, the returned object is a 1-d numpy
object array of Axes objects are returned as numpy 1-d arrays.

- for NxM subplots with N>1 and M>1 are returned as a 2d array.

If *False*, no squeezing at all is done: the returned object is
always a 2-d array of Axes instances, even if it ends up being 1x1.
- If True, extra dimensions are squeezed out from the returned
axis object:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'..the return object'


- if only one subplot is constructed (nrows=ncols=1), the
resulting single Axis object is returned as a scalar.
- for Nx1 or 1xN subplots, the returned object is a 1-d numpy
object array of Axis objects are returned as numpy 1-d
arrays.
Copy link
Contributor

@afvincent afvincent Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there an extra verb in this sentence? Wouldn't be OK something like: 'for Nx1 or 1xN subplots, the returned object is a 1-d numpy object array of Axes instances'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NelleV I think you may have missed this one.

- for NxM subplots with N>1 and M>1 are returned as a 2d
arrays.
Copy link
Contributor

@afvincent afvincent Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • '2-d array'?
  • Besides, I feel like some subject is missing (but my English may be wrong). I would have expected something like: 'for NxM subplots with N>1 and M>1, the returned object is a 2-d numpy object array of Axes instances.'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a comma is missing.


- If False, no squeezing at all is done: the returned axis object
is always a 2-d array containing Axis instances, even if it ends
up being 1x1.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't all the 'Axis' in ll.1058-1071 be replaced with 'Axes'? matplotlib.axis.Axis is different from matplotlib.axes.Axes, isn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a very important distinction!

subplot_kw : dict, default: {}
Dict with keywords passed to the
Expand Down
11 changes: 4 additions & 7 deletions 11 lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,13 +1047,10 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,

Parameters
----------
nrows : int, optional, default: 1
Number of rows of the subplot grid.
nrows, ncols : int, optional, default: 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'optional' is a bit weird as it is not precised for the other kwargs of subplots, neither in pyplot.py nor in figure.py.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, just not for sharex and sharey, and the only reason is that I can't be bothered to fix the fact that the line is then too long…
I'll let someone else fix that.

Number of rows/columns of the subplot grid.

ncols : int, optional, default: 1
Number of columns of the subplot grid.

sharex : bool or string, optional, default: False
sharex : {"none", "all", "row", "col"} or bool, default: False
- If True, the x-axis will be shared amongst all subplots.
- If False, no axis will be shared amongst subplots.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

axis -> x-axis

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'no x-axis'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch.

- If a string must be one of "row", "col", "all", or "none".
Expand All @@ -1066,7 +1063,7 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
sharex="col"), then the x tick labels will only be display on subplots
of the bottom row.

sharey : bool or string, optional, default: False
sharey : {"none", "all", "row", "col"} or bool, default: False
- If True, the y-axis will be shared amongst all subplots.
- If False, no y-axis will be shared amongst subplots.
- If a string must be one of "row", "col", "all", or "none".
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.