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

Skip to content

Autogenerate (via boilerplate) more of pyplot. #10934

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 1 commit into from
May 4, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Apr 1, 2018

PR Summary

... namely axis, minorticks_{on,off}, title, {x,y}lim, {x,y}scale, and sci.

This helps maintaining the signatures (cf. title) and docstring (cf. axis) in sync.

PR Checklist

  • 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

@anntzer anntzer added this to the v3.0 milestone Apr 1, 2018
"""
Display minor ticks on the axes.

Displaying minor ticks reduces performance; turn them off using
Copy link
Member

Choose a reason for hiding this comment

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

Is this really significant? If so, this is an implementation detail.

I would put it in a Note, and formulate a bit more defensive: "Displaying minor ticks may reduce performance. You may turn them off using ...`.

@@ -1601,7 +1601,8 @@ def apply_aspect(self, position=None):
self.set_xbound((x0, x1))

def axis(self, *v, **kwargs):
"""Set axis properties.
"""
Convenience method to get or set some axis properties.

Valid signatures::
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 we now use the term "Call signatures".


This image will be the target of colormap functions like
`~matplotlib.pyplot.viridis`, and other functions such as
`~matplotlib.pyplot.hot` or `~matplotlib.pyplot.clim`. The current
Copy link
Member

Choose a reason for hiding this comment

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

remove "hot". It's a cmap like viridis.

@anntzer
Copy link
Contributor Author

anntzer commented Apr 2, 2018

comments handled

changing dimensions of the plot box.
'tight' Set limits such that all data is shown; if this is already
the case, move data to the center of the figure without
modifying ``xmax-xmin`` or ``ymax-ymin``.
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand; what is an example of the second case, where the limits are changed without changing their differences?

Copy link
Member

@timhoffm timhoffm Apr 4, 2018

Choose a reason for hiding this comment

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

Indeed the description seems to be incorrect.

>>> fig, ax = plt.subplots()
>>> ax.plot([1,3,2])
>>> ax.get_xlim()
(-0.1, 2.1)

>>> ax.set_xlim(right=4.1)
(-0.1, 4.1)

>>> ax.axis('tight')
(-0.1, 2.1, 0.9, 3.1)

>>> ax.get_xlim()
(-0.1, 2.1)

From the description I would have anticipated (-1.1, 3.1). Anyway, the implemented behavior seems more reasonable. I don't see why 'tight' should preserve xmax-xmin. So the docstring should be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I just copied the pyplot docstring :-) Removed the offending sentence, although now it's unclear how this is different from "auto".

As a side note (but not changed by this PR), the docstring of autoscale() states that

        tight: bool or None, optional
            If True, set view limits to data limits;
            if False, let the locator and margins expand the view limits;
            if None, use tight scaling if the only artist is an image,
            otherwise treat *tight* as False.
            The *tight* setting is retained for future autoscaling
            until it is explicitly changed.

implying that autoscale=True ignores margins. But either that's not true, or axis('tight') has a different meaning per @timhoffm's example. Note also the docstring of autoscale_view:

        If *tight* is *False*, the axis major locator will be used
        to expand the view limits if rcParams['axes.autolimit_mode']
        is 'round_numbers'.  Note that any margins that are in effect
        will be applied first, regardless of whether *tight* is
        *True* or *False*.  Specifying *tight* as *True* or *False*
        saves the setting as a private attribute of the Axes; specifying
        it as *None* (the default) applies the previously saved value.

so is tight=False basically redundant with the axes.autolimit_mode rc? All that's very confusing...

@anntzer
Copy link
Contributor Author

anntzer commented May 2, 2018

rebased

@phobson phobson merged commit e4ce92f into matplotlib:master May 4, 2018
@anntzer anntzer deleted the more-autogen branch May 4, 2018 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants