@@ -322,7 +322,7 @@ def _split_path_and_get_label_rotation(self, path, idx, screen_pos, lw, spacing=
322
322
Parameters
323
323
----------
324
324
path : Path
325
- The path where the label will be inserted, in data space.
325
+ The path where the label will be inserted, in screen space.
326
326
idx : int
327
327
The vertex index after which the label will be inserted.
328
328
screen_pos : (float, float)
@@ -352,7 +352,7 @@ def _split_path_and_get_label_rotation(self, path, idx, screen_pos, lw, spacing=
352
352
if hasattr (self , "_old_style_split_collections" ):
353
353
del self ._old_style_split_collections # Invalidate them.
354
354
355
- xys = path .vertices
355
+ xys = self . get_transform (). inverted (). transform ( path .vertices )
356
356
codes = path .codes
357
357
358
358
# Insert a vertex at idx/pos (converting back to data space), if there isn't yet
@@ -582,7 +582,8 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
582
582
583
583
idx_level_min , idx_vtx_min , proj = self ._find_nearest_contour (
584
584
(x , y ), self .labelIndiceList )
585
- path = self ._paths [idx_level_min ]
585
+ path = self .get_transform ().transform_path (self ._paths [idx_level_min ])
586
+
586
587
level = self .labelIndiceList .index (idx_level_min )
587
588
label_width = self ._get_nth_label_width (level )
588
589
rotation , path = self ._split_path_and_get_label_rotation (
@@ -614,8 +615,9 @@ def labels(self, inline, inline_spacing):
614
615
trans = self .get_transform ()
615
616
label_width = self ._get_nth_label_width (idx )
616
617
additions = []
617
- for subpath in self ._paths [icon ]._iter_connected_components ():
618
- screen_xys = trans .transform (subpath .vertices )
618
+ for subpath in trans .transform_path (
619
+ self ._paths [icon ])._iter_connected_components ():
620
+ screen_xys = subpath .vertices
619
621
# Check if long enough for a label
620
622
if self .print_label (screen_xys , label_width ):
621
623
x , y , idx = self .locate_label (screen_xys , label_width )
@@ -626,7 +628,7 @@ def labels(self, inline, inline_spacing):
626
628
if inline : # If inline, add new contours
627
629
additions .append (path )
628
630
else : # If not adding label, keep old path
629
- additions .append (subpath )
631
+ additions .append (trans . inverted (). transform_path ( subpath ) )
630
632
# After looping over all segments on a contour, replace old path by new one
631
633
# if inlining.
632
634
if inline :
0 commit comments