Skip to content

DOC: add a semicolon to hide long matplotlib axes return value #34393

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 2 commits into from
May 28, 2020
Merged

DOC: add a semicolon to hide long matplotlib axes return value #34393

merged 2 commits into from
May 28, 2020

Conversation

partev
Copy link
Contributor

@partev partev commented May 26, 2020

add a semicolon to hide debug messages like:
Out[85]:
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0ad6e3d0>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0ad4a350>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0aa10250>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a6367d0>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d088c2d50>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d089ea310>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d08d89890>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a76ae10>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a756090>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a8dd750>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d096aaed0>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0937d490>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d09f49a10>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a0551d0>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a418550>,
<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a6f0ad0>]],
dtype=object)
which you can see here:

https://pandas.pydata.org/docs/user_guide/visualization.html

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

add a semicolon to hide debug messages like:
Out[85]: 
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0ad6e3d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0ad4a350>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0aa10250>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a6367d0>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d088c2d50>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d089ea310>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d08d89890>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a76ae10>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a756090>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a8dd750>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d096aaed0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0937d490>],
       [<matplotlib.axes._subplots.AxesSubplot object at 0x7f3d09f49a10>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a0551d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a418550>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x7f3d0a6f0ad0>]],
      dtype=object)
which you can see here:

https://pandas.pydata.org/docs/user_guide/visualization.html
@jreback jreback added the Docs label May 26, 2020
@@ -821,7 +821,7 @@ You can create a scatter plot matrix using the
df = pd.DataFrame(np.random.randn(1000, 4), columns=['a', 'b', 'c', 'd'])

@savefig scatter_matrix_kde.png
scatter_matrix(df, alpha=0.2, figsize=(6, 6), diagonal='kde')
scatter_matrix(df, alpha=0.2, figsize=(6, 6), diagonal='kde');
Copy link
Member

Choose a reason for hiding this comment

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

Does using plt.show() have the same effect? May look a bit more natural.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure how to do this using plt.show()

Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine. IPython will show any output of each line. So adding a plt.show() will not prevent printing the output of this line.

Copy link
Member

Choose a reason for hiding this comment

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

This seems like a strange one-off so would prefer what @dsaxton suggests if it works

IPython will show any output of each line.

Is that a general comment or specific to just doc rendering? Running this in ipython:

a = [1, 2, 3]
a
print("done")

Only prints "done"

Copy link
Member

Choose a reason for hiding this comment

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

Is that a general comment or specific to just doc rendering?

The IPython directive runs line by line (so it's not the same copy pasting it in an ipython console, but rather as copy pasting line by line)

This seems like a strange one-off

We already do this in several places in this visualization.rst, so it's not a one-off

Copy link
Member

Choose a reason for hiding this comment

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

Ah OK thanks for the explanation. lgtm to then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there are about 40 semicolons in visualization.rst but there are also many plots which don't have semicolons and show the debug messages.
Should we put a semicolon after every plot in visualization.rst?

@jorisvandenbossche jorisvandenbossche changed the title add a semicolon to hide debug messages DOC: add a semicolon to hide long matplotlib axes return value May 27, 2020
@jorisvandenbossche jorisvandenbossche added this to the 1.1 milestone May 27, 2020
@WillAyd WillAyd merged commit 63dda53 into pandas-dev:master May 28, 2020
@WillAyd
Copy link
Member

WillAyd commented May 28, 2020

Thanks @partev

@partev partev deleted the patch-2 branch May 28, 2020 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants