Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Clean up and move text rotation example #8066
Conversation
dstansby
added the
Documentation
label
Feb 12, 2017
| +Text rotation demonstration | ||
| +=========================== | ||
| + | ||
| +The way matplotlib does text layout is counter-intuitive to some, so |
phobson
Feb 13, 2017
Member
Maybe we could be a little gentler about this. Something like, "matplotlib takes a different approach to text layout..." (maybe?)
| +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 |
dstansby
Feb 14, 2017
Contributor
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) |
phobson
Feb 13, 2017
Member
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 |
| + | ||
| +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 |
|
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 |
NelleV
added this to the
2.1 (next point release)
milestone
Feb 16, 2017
|
I would just remove pylab_examples/demo_text_rotation_mode.py. |
NelleV
changed the title from
Clean up and move text rotation example to [MRG+1] Clean up and move text rotation example
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. |
|
Can someone else review this? I think this patch is ready to be merged, but it requires an extra review. |
| +import numpy as np | ||
| + | ||
| + | ||
| +def addtext(ax, props): |
| + | ||
| + | ||
| +def addtext(ax, props): | ||
| + ax.text(0.5, 0.5, 'text 0', props, rotation=0) |
QuLogic
Feb 24, 2017
Member
How about putting this in the loop too? for i, angle in enumerate([0, 45, 135, 225, -45]):
| +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), []) |
|
@QuLogic This PR modifies the docstring. The code was there before and @dstansby did not modify it. |
|
Only the docstring was modified, but that was enough for github to consider this not as a move, but as a deletion + modification.. @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. |
|
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. |
dstansby commentedFeb 12, 2017
No description provided.