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

Skip to content

DOCS: describe shared axes behavior with units #18353

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
Sep 8, 2020
Merged

DOCS: describe shared axes behavior with units #18353

merged 2 commits into from
Sep 8, 2020

Conversation

l-johnston
Copy link
Contributor

@l-johnston l-johnston commented Aug 25, 2020

PR Summary

Closes #18345

PR Checklist

  • [N/A] Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • [N/A] New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and pydocstyle<4 and run flake8 --docstring-convention=all).
  • [N/A] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@l-johnston
Copy link
Contributor Author

I attempted to create an example showing the behavior of set_units when shared axes have units, but there are many problems.

  1. The units examples rely on TaggedValue defined in basic_units.py. TaggedValue is a container based on numpy's dispatch mechanism where __array__ returns the underlying data as a base class ndarray - no more units. This breaks plotting functions like plot that, very early in execution, calls cbook._check_1d that calls np.atleast1d that calls __array__. Subsequent call to set_units then fails because the data, now ndarray has no units converter.
  2. Plotting functions like bar and scatter don't assign a 'units' callback, so the call to Axis.set_units does nothing. Unlike plot that does set a 'units' callback.
  3. I can change TaggedValue.__array__ to return an array of TaggedValue objects, but this breaks the ellipse example.

@l-johnston
Copy link
Contributor Author

@jklymak Is this proposed PR sufficient? Creating an example using the existing basic_units definition isn't going to work as discussed above. I read the units discourse and see that units has a rather long history. Is there any work on defining an interface layer between incoming data and plot function internals?

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Seems right? Are there other places where sharex/y are documented?

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.

@l-johnston This is good enough. We don't need an example.

Could you please also update the docstring of GridSpecBase.subplots() with the same paragraph.

@l-johnston l-johnston marked this pull request as ready for review September 8, 2020 13:07
@l-johnston l-johnston requested a review from jklymak September 8, 2020 15:26
@jklymak jklymak merged commit e26d497 into matplotlib:master Sep 8, 2020
@l-johnston l-johnston deleted the issue_18345 branch September 8, 2020 17:42
@QuLogic QuLogic added this to the v3.4.0 milestone Sep 8, 2020
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.

Specify what sharex and sharey do...
5 participants