-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Text alignment #1180
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
Comments
@2sn Did you submit a pull request for this? If so, was it merged? |
Dear Eric, was it included then? -Alexander On 22/07/13 12:46, Eric Firing wrote:
|
The PR is still open. The discussion seems to have raised some unresolved questions as to how to proceed. |
Hi,
I added a quick patch to allow numerical values for text alignment.
It now allows a number that is fraction of text hight or with and is measured relative to bottom or left. So
ha = 0 == 'left'
ha = 1 == 'right'
va = 0 == 'bottom'
va = 1 == 'top'
va/ha = 0.5 == 'center'
the cool thing is that values outside [0,1] allow you to some defined distance from a line or symbol that remains well-measured even if you interactively scale the figure.
Can you please add this to MPL?
(also fixed some typos in typo doc)
This is my first addition here, not sure how to add patches, I can submit a pull request it appears.
-Alexander
2sn/matplotlib@master...text-numeric-va-ha
From b167849f438e4b77319c51fd603946525823edc0 Mon Sep 17 00:00:00 2001
From: Alexander Heger [email protected]
Date: Fri, 31 Aug 2012 16:58:04 +1000
Subject: [PATCH 1/2] ADD - added numeric update for ha and va in Text
lib/matplotlib/text.py | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py
index b00e4cf..b1188de 100644
--- a/lib/matplotlib/text.py
+++ b/lib/matplotlib/text.py
@@ -10,7 +10,7 @@ from matplotlib import cbook
from matplotlib import rcParams
import matplotlib.artist as artist
from matplotlib.artist import Artist
-from matplotlib.cbook import is_string_like, maxdict
+from matplotlib.cbook import is_string_like, maxdict, is_numlike
from matplotlib import docstring
from matplotlib.font_manager import FontProperties
from matplotlib.patches import bbox_artist, YAArrow, FancyBboxPatch,
@@ -69,21 +69,21 @@ docstring.interpd.update(Text = """
family [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
figure a matplotlib.figure.Figure instance
fontproperties a matplotlib.font_manager.FontProperties instance
horizontalalignment or ha [ 'center' | 'right' | 'left' ]
horizontalalignment or ha [ 'center' | 'right' | 'left' | fraction text width from left ]
label any string
linespacing float
lod [True | False]
multialignment ['left' | 'right' | 'center' ]
name or fontname string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
position (x,y)
rotation [ angle in degrees 'vertical' | 'horizontal'
rotation [ angle in degrees | 'vertical' | 'horizontal' ]
rotation_mode [ None | 'anchor']
size or fontsize [ size in points | relative size eg 'smaller', 'x-large' ]
style or fontstyle [ 'normal' | 'italic' | 'oblique']
text string
transform a matplotlib.transform transformation instance
variant [ 'normal' | 'small-caps' ]
verticalalignment or va [ 'center' | 'top' | 'bottom' | 'baseline' ]
verticalalignment or va [ 'center' | 'top' | 'bottom' | 'baseline' | fraction text height from bottom ]
visible [True | False]
weight or fontweight [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
x float
@@ -378,25 +378,29 @@ class Text(Artist):
if rotation_mode != "anchor":
# compute the text location in display coords and the offsets
# necessary to align the bbox with that location
@@ -796,11 +800,11 @@ class Text(Artist):
"""
Set the horizontal alignment to one of
def set_ma(self, align):
@@ -811,7 +815,7 @@ class Text(Artist):
def set_multialignment(self, align):
"""
Set the alignment for multiple lines layout. The layout of the
@@ -957,11 +961,11 @@ class Text(Artist):
"""
Set the vertical alignment
1.7.11.4
From 076d2ef17d8bb25417ee805a9b9a9221918d230f Mon Sep 17 00:00:00 2001
From: Alexander Heger [email protected]
Date: Fri, 31 Aug 2012 17:05:23 +1000
Subject: [PATCH 2/2] BF typo
lib/matplotlib/text.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/matplotlib/text.py b/lib/matplotlib/text.py
index b1188de..a22dd64 100644
--- a/lib/matplotlib/text.py
+++ b/lib/matplotlib/text.py
@@ -815,7 +815,7 @@ class Text(Artist):
def set_multialignment(self, align):
"""
Set the alignment for multiple lines layout. The layout of the
1.7.11.4
The text was updated successfully, but these errors were encountered: