Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Changes to the pyplot api documentation #11620

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

Closed
wants to merge 1 commit into from

Conversation

fredrik-1
Copy link
Contributor

I did some formatting to the pyplot api page. The sections are mostly taken from the sections in the pyplot.py file.

I took away the colormaps section as it is a function in pyplot anyway.

These changes make it much easier to find out about the pyplot functions.

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

autoscale
axhline
axhspan
axis

Choose a reason for hiding this comment

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

Those are no plotting functions: axis, cla, grid, sci, polar, xlabel, ylabel, set_cmap, title, xscale, yscale etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, thats true. They are in the plotting section of pyplot though and I haven't look through that part in much detail.

@ImportanceOfBeingErnest
Copy link
Member

Are you proposing to delete the "Colors" section? Or where would you put it instead?

@fredrik-1
Copy link
Contributor Author

The color section where mostly the docstring for the pyplot.colormap function and I think that the section can be taken away. I don't think that it should be explicitly in the pyplot api anyway.

One possibility if a section with that name should exist somewhere due to links is to put it on its own page in the api list.

@ImportanceOfBeingErnest
Copy link
Member

Yes that was already the idea in the last PR. But simply deleting it is not an option.

@fredrik-1 fredrik-1 force-pushed the pyplot_api branch 2 times, most recently from 44bd036 to db07723 Compare July 10, 2018 21:03
@fredrik-1
Copy link
Contributor Author

I took out the non plotting functions from the plotting functions. I hope I got it mostly correct.

About the color section. I thought that the discussion in that pr was mostly about other things.

The only part I delete in this PR is

There are many colormaps you can use to map data onto color values. Below we list several ways in which color can be utilized in Matplotlib.

For a more in-depth look at colormaps, see the Colormaps in Matplotlib tutorial.

The rest is in pyplot.colormaps that is linked to on the pyplot_api page.

The problems I see with my approach.

  • It is possible that there are links to the old section in the documentation.
  • It might be good to have that information in an easy to find place.

I am not sure of either of these two problems but I don't see how that section could have been linked and there are already acm (colormaps)and a colors section on the api page.

I can look through the information that exist today and propose a solution.

@tacaswell tacaswell added this to the v2.2-doc milestone Jul 10, 2018
@tacaswell
Copy link
Member

I have a preference for keeping this content in the file pyplot_summary because that name ends up as part of the URL so by making the same change we will be breaking peoples bookmarks (and making the mixed version in the top-level docs problem worse).

@tacaswell
Copy link
Member

I am very 👍 on the overall idea and the organization!

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Thanks! This is a great improvement.

I'm pondering if we should group the functions a bit differently, e.g. put all the image functions together. But that could still be done later on if desired.

setp
xkcd

Making figures
Copy link
Member

Choose a reason for hiding this comment

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

"Creating figures" is the more common term.


.. currentmodule:: matplotlib.pyplot

.. automodule:: matplotlib.pyplot
Copy link
Member

Choose a reason for hiding this comment

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

The module description is a bit out of place now. It should probably be a one-sentence description and reference the pyplot API section in API overview and maybe the pyplot tutorial.

A discussion vs the OOP approach and an example are unnecessary here.

:template: autosummary.rst
:nosignatures:

getp
Copy link
Member

Choose a reason for hiding this comment

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

getp does not link because it does not live in pyplot. It's just imported. Can we do something about this?

savefig
waitforbuttonpress

Putting things in figures
Copy link
Member

Choose a reason for hiding this comment

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

Sound a bit clumsy. Maybe "Adding elements to figures"?

sci
set_cmap

Putting things in axes
Copy link
Member

Choose a reason for hiding this comment

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

Adding elements to axes?

figtext
suptitle

Working with axes
Copy link
Member

Choose a reason for hiding this comment

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

Should this be capital "Axes"?

Possibly as well in other headlines?

@dstansby
Copy link
Member

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

This looks so much better, thanks a lot 👍 . I have a few small comments, which I've put inline.


Any artist
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean? Functions that can be used by any artist? Or functions that are applied to every artist on the plot?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are functions that can be applied to every artist. The name was just taken from thepyplot file.


For a more in-depth look at colormaps, see the
:doc:`/tutorials/colors/colormaps` tutorial.
Making figures
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 this should be moved to the top, since this is the one bit of the pyplots stuff everyone has to use even if they then use the object oriented API.

Copy link
Member

@timhoffm timhoffm Jul 11, 2018

Choose a reason for hiding this comment

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

And it's the first thing to do in a plot 😄

Generally, I would roughly sort the sections by how often a typical user may need them. While on the other hand, keeping related topics together. e.g. putting things in figures either next to putting things in axes or next to working with figures.

By the way, do you want to stick to the putting things wording?


Working with axes
=================

Copy link
Member

Choose a reason for hiding this comment

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

Might be worth putting a single sentence here saying what an axes is (as opposed to an axis)


Working with axis
=================

Copy link
Member

Choose a reason for hiding this comment

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

Might be worth putting a single sentence here saying what an axis is (as opposed to an axes)


Current image
=============

Copy link
Member

Choose a reason for hiding this comment

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

Current image doesn't mean much to me, might be worth putting a single sentence here too.

imread
imsave

Plotting functions
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth moving this up too, since these are probably the second most common set of functions that people use.

@fredrik-1 fredrik-1 force-pushed the pyplot_api branch 3 times, most recently from aaf0652 to 2bc5466 Compare July 18, 2018 21:15
@fredrik-1
Copy link
Contributor Author

fredrik-1 commented Jul 18, 2018

I finally did some changes.

I kind of like the ordering in pyplot_summary in large. I think that the most important pyplot functions are the ones for creating figures, the global functions and the ones for any artist. The rest are not really necessary.

I looked through the color documentation and I think that the docstring in pyplot.colormaps are an old version of the colormap tutorial. I don't think that it is good to have similar documentation at different places so I deleted a large part of the docstring.

I made the links to the two most important color tutorials on the color_api page explicit.

It was not clearly documented that the matplotlib.cm module has a dictionary with all colormaps or that every colormap is an attribute to the module. I tried to write that in the module docstring as a numpydoc docstring but it didn't work for some reason.

new version

@jklymak
Copy link
Member

jklymak commented Apr 15, 2021

@fredrik-1 Thanks so much for your efforts with the docs. This is really out of date, so I'm going to close, but please feel free to rebase if you think there are helpful changes to the current docs in here... Sorry this didn't get over the line!

@jklymak jklymak closed this Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants