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

Skip to content

Commit bff7ef5

Browse files
committed
Add warning for mixing AnchoredText with bad kwarg
Mixing 'ha' or 'va' with AnchoredText produces bad output, so add a warning in this case.
1 parent d6414c7 commit bff7ef5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717

1818
from __future__ import print_function
19+
import warnings
1920
import matplotlib.transforms as mtransforms
2021
import matplotlib.artist as martist
2122
import matplotlib.text as mtext
@@ -1098,6 +1099,12 @@ def __init__(self, s, loc, pad=0.4, borderpad=0.5, prop=None, **kwargs):
10981099
other keyword parameters of AnchoredOffsetbox are also allowed.
10991100
"""
11001101

1102+
propkeys = prop.keys()
1103+
badkwargs = ('ha', 'horizontalalignment', 'va', 'verticalalignment')
1104+
if set(badkwargs) & set(propkeys):
1105+
warnings.warn("Mixing horizontalalignment or verticalalignment "
1106+
"with AnchoredText is not supported.")
1107+
11011108
self.txt = TextArea(s, textprops=prop,
11021109
minimumdescent=False)
11031110
fp = self.txt._text.get_fontproperties()

0 commit comments

Comments
 (0)