@@ -2899,29 +2899,12 @@ def __init__(self, beginarrow=None, endarrow=None,
2899
2899
super (ArrowStyle ._Curve , self ).__init__ ()
2900
2900
2901
2901
2902
- def _get_pad_projected (self , x0 , y0 , x1 , y1 , linewidth ):
2903
- # when no arrow head is drawn
2904
-
2905
- dx , dy = x0 - x1 , y0 - y1
2906
- cp_distance = math .sqrt (dx ** 2 + dy ** 2 )
2907
-
2908
- # padx_projected, pady_projected : amount of pad to account
2909
- # projection of the wedge
2910
- padx_projected = (.5 * linewidth )
2911
- pady_projected = (.5 * linewidth )
2912
-
2913
- # apply pad for projected edge
2914
- ddx = padx_projected * dx / cp_distance
2915
- ddy = pady_projected * dy / cp_distance
2916
-
2917
- return ddx , ddy
2918
-
2919
2902
def _get_arrow_wedge (self , x0 , y0 , x1 , y1 ,
2920
2903
head_dist , cos_t , sin_t , linewidth
2921
2904
):
2922
2905
"""
2923
2906
Return the paths for arrow heads. Since arrow lines are
2924
- drawn with capstyle=projected, The arrow is goes beyond the
2907
+ drawn with capstyle=projected, The arrow goes beyond the
2925
2908
desired point. This method also returns the amount of the path
2926
2909
to be shrinked so that it does not overshoot.
2927
2910
"""
@@ -2932,14 +2915,13 @@ def _get_arrow_wedge(self, x0, y0, x1, y1,
2932
2915
dx , dy = x0 - x1 , y0 - y1
2933
2916
cp_distance = math .sqrt (dx ** 2 + dy ** 2 )
2934
2917
2935
- # padx_projected, pady_projected : amount of pad for account
2936
- # the overshooting of the projection of the wedge
2937
- padx_projected = (.5 * linewidth / cos_t )
2938
- pady_projected = (.5 * linewidth / sin_t )
2918
+ # pad_projected : amount of pad to account the
2919
+ # overshooting of the projection of the wedge
2920
+ pad_projected = (.5 * linewidth / sin_t )
2939
2921
2940
2922
# apply pad for projected edge
2941
- ddx = padx_projected * dx / cp_distance
2942
- ddy = pady_projected * dy / cp_distance
2923
+ ddx = pad_projected * dx / cp_distance
2924
+ ddy = pad_projected * dy / cp_distance
2943
2925
2944
2926
# offset for arrow wedge
2945
2927
dx , dy = dx / cp_distance * head_dist , dy / cp_distance * head_dist
@@ -2948,7 +2930,7 @@ def _get_arrow_wedge(self, x0, y0, x1, y1,
2948
2930
dx2 , dy2 = cos_t * dx - sin_t * dy , sin_t * dx + cos_t * dy
2949
2931
2950
2932
vertices_arrow = [(x1 + ddx + dx1 , y1 + ddy + dy1 ),
2951
- (x1 + ddx , y1 + + ddy ),
2933
+ (x1 + ddx , y1 + ddy ),
2952
2934
(x1 + ddx + dx2 , y1 + ddy + dy2 )]
2953
2935
codes_arrow = [Path .MOVETO ,
2954
2936
Path .LINETO ,
@@ -3625,6 +3607,7 @@ def __init__(self, posA=None, posB=None,
3625
3607
shrinkB = 2. ,
3626
3608
mutation_scale = 1. ,
3627
3609
mutation_aspect = None ,
3610
+ dpi_cor = 1. ,
3628
3611
** kwargs ):
3629
3612
"""
3630
3613
If *posA* and *posB* is given, a path connecting two point are
@@ -3692,8 +3675,26 @@ def __init__(self, posA=None, posB=None,
3692
3675
self ._mutation_scale = mutation_scale
3693
3676
self ._mutation_aspect = mutation_aspect
3694
3677
3678
+ self .set_dpi_cor (dpi_cor )
3695
3679
#self._draw_in_display_coordinate = True
3696
3680
3681
+ def set_dpi_cor (self , dpi_cor ):
3682
+ """
3683
+ dpi_cor is currently used for linewidth-related things and
3684
+ shink factor. Mutation scale is not affected by this.
3685
+ """
3686
+
3687
+ self ._dpi_cor = dpi_cor
3688
+
3689
+ def get_dpi_cor (self ):
3690
+ """
3691
+ dpi_cor is currently used for linewidth-related things and
3692
+ shink factor. Mutation scale is not affected by this.
3693
+ """
3694
+
3695
+ return self ._dpi_cor
3696
+
3697
+
3697
3698
def set_positions (self , posA , posB ):
3698
3699
""" set the begin end end positions of the connecting
3699
3700
path. Use current vlaue if None.
@@ -3814,8 +3815,8 @@ def get_mutation_aspect(self):
3814
3815
def get_path (self ):
3815
3816
"""
3816
3817
return the path of the arrow in the data coordinate. Use
3817
- get_path_in_displaycoord() medthod to retrieve the arrow path
3818
- in the disaply coord.
3818
+ get_path_in_displaycoord() method to retrieve the arrow path
3819
+ in the disaply coord.
3819
3820
"""
3820
3821
_path , fillable = self .get_path_in_displaycoord ()
3821
3822
@@ -3830,14 +3831,16 @@ def get_path_in_displaycoord(self):
3830
3831
Return the mutated path of the arrow in the display coord
3831
3832
"""
3832
3833
3834
+ dpi_cor = self .get_dpi_cor ()
3835
+
3833
3836
if self ._posA_posB is not None :
3834
3837
posA = self .get_transform ().transform_point (self ._posA_posB [0 ])
3835
3838
posB = self .get_transform ().transform_point (self ._posA_posB [1 ])
3836
3839
_path = self .get_connectionstyle ()(posA , posB ,
3837
3840
patchA = self .patchA ,
3838
3841
patchB = self .patchB ,
3839
- shrinkA = self .shrinkA ,
3840
- shrinkB = self .shrinkB
3842
+ shrinkA = self .shrinkA * dpi_cor ,
3843
+ shrinkB = self .shrinkB * dpi_cor
3841
3844
)
3842
3845
else :
3843
3846
_path = self .get_transform ().transform_path (self ._path_original )
@@ -3846,7 +3849,7 @@ def get_path_in_displaycoord(self):
3846
3849
3847
3850
_path , fillable = self .get_arrowstyle ()(_path ,
3848
3851
self .get_mutation_scale (),
3849
- self .get_linewidth (),
3852
+ self .get_linewidth ()* dpi_cor ,
3850
3853
self .get_mutation_aspect ()
3851
3854
)
3852
3855
@@ -3887,7 +3890,11 @@ def draw(self, renderer):
3887
3890
if self ._hatch :
3888
3891
gc .set_hatch (self ._hatch )
3889
3892
3890
-
3893
+ # FIXME : dpi_cor is for the dpi-dependecy of the
3894
+ # linewidth. There could be room for improvement.
3895
+ #
3896
+ #dpi_cor = renderer.points_to_pixels(1.)
3897
+ self .set_dpi_cor (renderer .points_to_pixels (1. ))
3891
3898
path , fillable = self .get_path_in_displaycoord ()
3892
3899
3893
3900
if not cbook .iterable (fillable ):
@@ -3940,6 +3947,7 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None,
3940
3947
mutation_scale = 10. ,
3941
3948
mutation_aspect = None ,
3942
3949
clip_on = False ,
3950
+ dpi_cor = 1. ,
3943
3951
** kwargs ):
3944
3952
"""
3945
3953
Connect point *xyA* in *coordsA* with point *xyB* in *coordsB*
@@ -4013,6 +4021,7 @@ def __init__(self, xyA, xyB, coordsA, coordsB=None,
4013
4021
mutation_scale = mutation_scale ,
4014
4022
mutation_aspect = mutation_aspect ,
4015
4023
clip_on = clip_on ,
4024
+ dpi_cor = dpi_cor ,
4016
4025
** kwargs )
4017
4026
4018
4027
# if True, draw annotation only if self.xy is inside the axes
@@ -4144,6 +4153,8 @@ def get_path_in_displaycoord(self):
4144
4153
Return the mutated path of the arrow in the display coord
4145
4154
"""
4146
4155
4156
+ dpi_cor = self .get_dpi_cor ()
4157
+
4147
4158
x , y = self .xy1
4148
4159
posA = self ._get_xy (x , y , self .coords1 , self .axesA )
4149
4160
@@ -4153,15 +4164,15 @@ def get_path_in_displaycoord(self):
4153
4164
_path = self .get_connectionstyle ()(posA , posB ,
4154
4165
patchA = self .patchA ,
4155
4166
patchB = self .patchB ,
4156
- shrinkA = self .shrinkA ,
4157
- shrinkB = self .shrinkB
4167
+ shrinkA = self .shrinkA * dpi_cor ,
4168
+ shrinkB = self .shrinkB * dpi_cor
4158
4169
)
4159
4170
4160
4171
4161
4172
4162
4173
_path , fillable = self .get_arrowstyle ()(_path ,
4163
4174
self .get_mutation_scale (),
4164
- self .get_linewidth (),
4175
+ self .get_linewidth ()* dpi_cor ,
4165
4176
self .get_mutation_aspect ()
4166
4177
)
4167
4178
0 commit comments