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

Skip to content

Commit 212a8f9

Browse files
committed
Merge pull request matplotlib#2070 from mdboom/issue2070
incorrect bbox of text
2 parents 33faad1 + ee3af29 commit 212a8f9

File tree

642 files changed

+3932
-3612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

642 files changed

+3932
-3612
lines changed

doc/users/whats_new.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ so that search results are printed prettily:
230230
'ytick.major.size': 4,
231231
'ytick.minor.size': 2})
232232

233-
Better vertical text alignment
234-
------------------------------
233+
Better vertical text alignment and multi-line text
234+
--------------------------------------------------
235235

236236
The vertical alignment of text is now consistent across backends. You
237237
may see small differences in text placement, particularly with rotated
@@ -241,6 +241,9 @@ If you are using a custom backend, note that the `draw_text` renderer
241241
method is now passed the location of the baseline, not the location of
242242
the bottom of the text bounding box.
243243

244+
Multi-line text will now leave enough room for the height of very tall
245+
or very low text, such as superscripts and subscripts.
246+
244247
``savefig.jpeg_quality`` added to rcParams
245248
------------------------------------------------------------------------------
246249
``rcParam`` value ``savefig.jpeg_quality`` was added so that the user can
@@ -1152,6 +1155,5 @@ Here are the 0.98.4 notes from the CHANGELOG::
11521155
arrays are now converted to arrays with NaNs for consistent
11531156
handling of masks and NaNs - MGD and EF
11541157

1155-
Added support for arbitrary rasterization resolutions to the SVG
1158+
Added support for arbitrary rasterization resolutions to the SVG
11561159
backend. - MW
1157-

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
235235
w, h, d = self.get_text_width_height_descent(s, prop, ismath)
236236
xd = d * np.sin(np.deg2rad(angle))
237237
yd = d * np.cos(np.deg2rad(angle))
238-
x = np.round(x - xd)
238+
x = np.round(x + xd)
239239
y = np.round(y + yd)
240240

241241
self._renderer.draw_text_image(Z, x, y, angle, gc)

lib/matplotlib/offsetbox.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,13 +718,10 @@ def get_extent(self, renderer):
718718
_, h_, d_ = renderer.get_text_width_height_descent(
719719
"lp", self._text._fontproperties, ismath=False)
720720

721-
bbox, info = self._text._get_layout(renderer)
721+
bbox, info, d = self._text._get_layout(renderer)
722722
w, h = bbox.width, bbox.height
723723

724724
line = info[-1][0] # last line
725-
_, hh, dd = renderer.get_text_width_height_descent(
726-
line, self._text._fontproperties, ismath=ismath)
727-
d = dd # the baseline of the last line
728725

729726
self._baseline_transform.clear()
730727

Binary file not shown.
Loading

lib/matplotlib/tests/baseline_images/test_axes/markevery.svg

Lines changed: 263 additions & 263 deletions
Loading
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_axes/markevery_line.svg

Lines changed: 275 additions & 275 deletions
Loading
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)