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

Skip to content

Clean up and move text rotation example #8066

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 4 commits into from
Feb 25, 2017

Conversation

dstansby
Copy link
Member

No description provided.

Text rotation demonstration
===========================

The way matplotlib does text layout is counter-intuitive to some, so
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could be a little gentler about this. Something like, "matplotlib takes a different approach to text layout..." (maybe?)

Copy link
Member

Choose a reason for hiding this comment

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

matplotlib -> Matplotlib

aligned by it's bounding box (the rectangular box that surrounds the
ink rectangle). The order of operations is rotation then
alignment, rather than alignment then rotation. Basically, the text
is centered at your x,y location, rotated around this point, and then
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 true with e.g., rotation_mode='anchor' and ha='right'?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think probably not.

It might be worth having an example for the default rotation mode (this example), and an example for the 'anchor' rotation mode (to replace http://matplotlib.org/devdocs/examples/pylab_examples/demo_text_rotation_mode.html)

ax.text(4.5, 0.5, 'text -45', props, rotation=-45)
ax.set_yticks([0, .5, 1])
ax.set_xlim(0, 5)
ax.grid(True)
Copy link
Member

Choose a reason for hiding this comment

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

Would love to see some of the different rotation modes in this example similar to this: http://matplotlib.org/devdocs/examples/pylab_examples/demo_text_rotation_mode.html

Text rotation demonstration
===========================

The way matplotlib does text layout is counter-intuitive to some, so
Copy link
Member

Choose a reason for hiding this comment

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

matplotlib -> Matplotlib


The way matplotlib does text layout is counter-intuitive to some, so
this example is designed to make it a little clearer. The text is
aligned by it's bounding box (the rectangular box that surrounds the
Copy link
Member

Choose a reason for hiding this comment

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

it's -> its

@dstansby
Copy link
Member Author

I've tidied up the docstring, and also scattered the text anchor points which I think makes the demo easier to understand.

Does anyone have any thoughts on leaving this as a demo of the default text rotation demonstration, and replacing http://matplotlib.org/devdocs/examples/pylab_examples/demo_text_rotation_mode.html with a demo of the 'anchor' mode of text rotation?

@NelleV NelleV added this to the 2.1 (next point release) milestone Feb 16, 2017
Copy link
Member

@NelleV NelleV left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@NelleV
Copy link
Member

NelleV commented Feb 16, 2017

I would just remove pylab_examples/demo_text_rotation_mode.py.

@NelleV NelleV changed the title Clean up and move text rotation example [MRG+1] Clean up and move text rotation example Feb 16, 2017
@NelleV
Copy link
Member

NelleV commented Feb 16, 2017

I gave my approval, but it'd be nice before we merged this one if you could do a small summary of all related examples in the gallery (ie, text rotation examples) and to merge and delete as many as possible.

@NelleV
Copy link
Member

NelleV commented Feb 23, 2017

Can someone else review this? I think this patch is ready to be merged, but it requires an extra review.



def addtext(ax, props):
ax.text(0.5, 0.5, 'text 0', props, rotation=0)
Copy link
Member

Choose a reason for hiding this comment

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

How about putting this in the loop too? for i, angle in enumerate([0, 45, 135, 225, -45]):

import numpy as np


def addtext(ax, props):
Copy link
Member

Choose a reason for hiding this comment

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

This function does more than just add text.

fig, axs = plt.subplots(2, 1)

addtext(axs[0], {'ha': 'center', 'va': 'center', 'bbox': bbox})
axs[0].set_xticks(np.arange(0, 5.1, 0.5), [])
Copy link
Member

Choose a reason for hiding this comment

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

This could be done in the (suitably-renamed) addtext.

@NelleV
Copy link
Member

NelleV commented Feb 24, 2017

@QuLogic This PR modifies the docstring. The code was there before and @dstansby did not modify it.
I don't think we should be asking contributors to clean up the mess that was there before, in particular in the case of documentation focused PR. Else, our documentation is just never going to improve.

@QuLogic
Copy link
Member

QuLogic commented Feb 24, 2017

Hmm, good point, but @dstansby did modify it or it would have shown as a single move, not two separate files. And because it's @dstansby and not a new contributor, I know he can handle it ;)

@NelleV
Copy link
Member

NelleV commented Feb 24, 2017

Only the docstring was modified, but that was enough for github to consider this not as a move, but as a deletion + modification..
It is just that in general, I think we are asking too much for our documentation patches: many people just give up on improving documentation on Matplotlib, as it is often harder than contributing code.

@dstansby Let us know if you'd like to fix the core content of the example, or whether you'd rather have this merged as-is.

@dstansby
Copy link
Member Author

Hello, I would prefer this to be merged as is - I only intended it to be a MEP-12 clean and a move, and if anyone wants to change what the example does they can always open another PR.

@NelleV NelleV merged commit 65201e0 into matplotlib:master Feb 25, 2017
@QuLogic QuLogic changed the title [MRG+1] Clean up and move text rotation example Clean up and move text rotation example Feb 26, 2017
@dstansby dstansby deleted the doc-text-rotation branch April 2, 2017 16:44
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.

4 participants