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

Skip to content

Sync 3D errorbar with 2D #18436

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 5 commits into from
Feb 19, 2021
Merged

Sync 3D errorbar with 2D #18436

merged 5 commits into from
Feb 19, 2021

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Sep 8, 2020

PR Summary

This fixes some inconsistencies of the 3D errorbar WRT the 2D version. Some of this is code rearrangement and cycler handling to match #17930.

Additionally, there's some inconsistency with caps for limited sides. Previously, they were drawn from a point on the line to the errorbar length with the arrow head ending on it. In 2D, the triangle marker starts at the errorbar length. As a consequence of fixing this, the arrow_length_ratio is no longer exposed. Also, when both limits are disabled, the 2D code places both caps at zero offset, but 3D placed them at default errorbar length (this is the case for the second-last errorbar in the test image).

All that being said, the size of arrows for caps are currently calculated somewhat arbitrarily in order to match the look of the test image. Unlike 2D, the 3D quiver arrows are not sized for display, but in data space. So I need to investigate that, and this will currently be marked as draft.

PR Checklist

  • 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).

@tacaswell
Copy link
Member

I am 👍 on this PR.

@QuLogic QuLogic added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Oct 20, 2020
@QuLogic QuLogic force-pushed the errorbar3d branch 2 times, most recently from 53028b4 to 2f2cc5a Compare February 4, 2021 20:28
@QuLogic QuLogic marked this pull request as ready for review February 4, 2021 20:58
@QuLogic
Copy link
Member Author

QuLogic commented Feb 4, 2021

I'll call this done on 80%/20%, but might have a followup later.

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

👍

left one super minor comment.

@tacaswell
Copy link
Member

If no one else reviews this in the next 6 or so hours I am going to merge this on a single review.

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.

I guess I'm concerned that a lot of this is untested... But not concerned enough to block.

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

modulo test change discussed today.

These variables are not used within these `if` blocks, and aren't meant
to be used outside of them either.
Namely, kwarg normalization, unit info processing, and adding a default
`data_line`, so it works when `fmt='none'`.

Move iterable checks before working on styling.

Also, move `errorevery` checks to a similar location as the 2D code.
As with 2D before matplotlib#17930, it would not cycle if a color were specified.
However, this does not match `plot`, which does not advance the cycle
only if _all_ properties in the cycle are specified. Notably, this means
if your property cycle was for line style, specifying a color would
ignore the cycle in `errorbar`, but not in `plot`.

This is a 3D version of 149e7fb and
0782c74.
There are a few differences that cause some image changes:
* When both upper and lower limits are True, `errorbar3d` incorrectly
  used full errorbar length for them. They should both have 0 errorbar
  with the arrow-head cap.
* The arrow-head cap should use `eb_cap_style`, not `eb_lines_style`.
  This meant that the capsize defaulted to 0, so this was made
  explicitly non-zero in the test.
* The baseline of the triangle (bottom/top for caps above/below a line)
  in 2D is aligned with the end of the errorbar, *not* the tip of the
  triangle, so all quivers in 3D shifted outward to match.
* The quiver would preferably not overlap the existing errorbar, which
  I've hopefully achieved by setting the length based on `capsize`, and
  using the above positioning. Consequently, `arrow_length_ratio` is no
  longer exposed.
@QuLogic
Copy link
Member Author

QuLogic commented Feb 18, 2021

For reference on the change in lib/mpl_toolkits/tests/baseline_images/test_mplot3d/errorbar3d.png, in 2D here is how the uplim=lolim=True case is rendered:

ax.errorbar(np.arange(5), np.arange(5), 1,
            lolims=[False, True, False, True, False],
            uplims=[False, False, True, True, True])

Figure_1

@tacaswell tacaswell merged commit 0f83ee2 into matplotlib:master Feb 19, 2021
@QuLogic QuLogic deleted the errorbar3d branch February 19, 2021 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: consistency Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: mplot3d
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants