Skip to content

Custom pivot for barbs#5391

Merged
QuLogic merged 5 commits intomatplotlib:masterfrom
dopplershift:tweak-barbs
May 28, 2017
Merged

Custom pivot for barbs#5391
QuLogic merged 5 commits intomatplotlib:masterfrom
dopplershift:tweak-barbs

Conversation

@dopplershift
Copy link
Copy Markdown
Contributor

This expands the pivot kwarg to take a float value, allowing the user to manually specify where the barb should start. This allows, for instance, the barbs to be offset outward from the center plot, freeing the center for other plot elements.

In meteorology, this is useful for standard plots where sky cover should be at the center, not the end of the wind barb.

@mdboom
Copy link
Copy Markdown
Member

mdboom commented Nov 4, 2015

A picture example?

@tacaswell tacaswell added this to the proposed next point release (2.1) milestone Nov 4, 2015
@dopplershift
Copy link
Copy Markdown
Contributor Author

Like this:
image

@dopplershift
Copy link
Copy Markdown
Contributor Author

Rebased and added a test for the new pivot.

@tacaswell tacaswell changed the title Custom pivot for barbs [MRG+1] Custom pivot for barbs May 8, 2017
@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented May 9, 2017

It appears that your email address changed... Anyway, the test is failing either way.

@dopplershift
Copy link
Copy Markdown
Contributor Author

Great, a 2 pixel difference (the end of one of the barbs), at least on windows and Python 2.7. I just can't wait to figure this one out.

This gives the user more control over where the barb pivots. The chief
use case is to allow having the barb end offset from the center, to
allow room for other plot elements.
@dopplershift
Copy link
Copy Markdown
Contributor Author

Fixed the email. The test failure was two pixels at the end of one of the barbs, only on windows/linux. I tweaked the test to just hopefully avoid it. (I started digging in, but the point locations generated across the versions were identical, which means the difference was somewhere in the drawing code...)

@dopplershift dopplershift force-pushed the tweak-barbs branch 2 times, most recently from 6b46cba to da4fe92 Compare May 11, 2017 21:45
@dopplershift
Copy link
Copy Markdown
Contributor Author

Ok, everything is green! :shipit:

Comment thread lib/matplotlib/quiver.py Outdated
entire barb should be rotated. Right now, valid options are
'head' and 'middle'.
'tip' and 'middle'. Can also be a number, which shifts the start
of the barb that many units from the origin.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But what "units" is it? Pixels?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What units are polygons/paths/markers normally in? I don't think it's pixels, but it's not data coordinates either.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd have thought points, but the scatter size is defined in points. I don't remember the scaling, but if it's a square, then the radius is √49/2 = 3.5. If it's actual circular area, it's √(49/π) = 3.949. But neither of these seem to match the shift defined in the test of 1.7, so I'm still not sure.

Copy link
Copy Markdown
Member

@QuLogic QuLogic May 13, 2017

Choose a reason for hiding this comment

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

It looks like the default pivot uses some factor of length and length is defined in points, so I guess this should be points.

BTW, in looking through this, I found a typo in the docs; do you mind fixing it here?

This section says the default length is 9, but the default appears to be 7.

Clarify units and make sure top-level barbs docstring reflects the new
ability to pass a float for pivot.
@dopplershift
Copy link
Copy Markdown
Contributor Author

Does that work for you @QuLogic ?

@QuLogic QuLogic merged commit 268420b into matplotlib:master May 28, 2017
@QuLogic QuLogic changed the title [MRG+1] Custom pivot for barbs Custom pivot for barbs May 28, 2017
@dopplershift dopplershift deleted the tweak-barbs branch May 30, 2017 17:13
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.

4 participants