@@ -3997,7 +3997,7 @@ def transmute(self, path, mutation_size, linewidth):
3997
3997
3998
3998
class FancyArrowPatch (Patch ):
3999
3999
"""
4000
- A fancy arrow patch. It draws an arrow using the :class:ArrowStyle.
4000
+ A fancy arrow patch. It draws an arrow using the :class:` ArrowStyle` .
4001
4001
"""
4002
4002
_edge_default = True
4003
4003
@@ -4006,10 +4006,10 @@ def __str__(self):
4006
4006
if self ._posA_posB is not None :
4007
4007
(x1 , y1 ), (x2 , y2 ) = self ._posA_posB
4008
4008
return self .__class__ .__name__ \
4009
- + "(%g,%g->%g,%g)" % (x1 , y1 , x2 , y2 )
4009
+ + "(%g,%g->%g,%g)" % (x1 , y1 , x2 , y2 )
4010
4010
else :
4011
4011
return self .__class__ .__name__ \
4012
- + "(%s)" % (str (self ._path_original ),)
4012
+ + "(%s)" % (str (self ._path_original ),)
4013
4013
4014
4014
@docstring .dedent_interpd
4015
4015
def __init__ (self , posA = None , posB = None ,
@@ -4020,46 +4020,80 @@ def __init__(self, posA=None, posB=None,
4020
4020
connector = None ,
4021
4021
patchA = None ,
4022
4022
patchB = None ,
4023
- shrinkA = 2. ,
4024
- shrinkB = 2. ,
4025
- mutation_scale = 1. ,
4023
+ shrinkA = 2 ,
4024
+ shrinkB = 2 ,
4025
+ mutation_scale = 1 ,
4026
4026
mutation_aspect = None ,
4027
- dpi_cor = 1. ,
4027
+ dpi_cor = 1 ,
4028
4028
** kwargs ):
4029
4029
"""
4030
- If *posA* and *posB* is given, a path connecting two point are
4031
- created according to the connectionstyle. The path will be
4030
+ If *posA* and *posB* are given, a path connecting two points is
4031
+ created according to * connectionstyle* . The path will be
4032
4032
clipped with *patchA* and *patchB* and further shrunken by
4033
4033
*shrinkA* and *shrinkB*. An arrow is drawn along this
4034
- resulting path using the *arrowstyle* parameter. If *path*
4035
- provided, an arrow is drawn along this path and *patchA*,
4036
- *patchB*, *shrinkA*, and *shrinkB* are ignored.
4034
+ resulting path using the *arrowstyle* parameter.
4037
4035
4038
- The *connectionstyle* describes how *posA* and *posB* are
4039
- connected. It can be an instance of the ConnectionStyle class
4040
- (matplotlib.patches.ConnectionStlye) or a string of the
4041
- connectionstyle name, with optional comma-separated
4042
- attributes. The following connection styles are available.
4036
+ Alternatively if *path* is provided, an arrow is drawn along this path
4037
+ and *patchA*, *patchB*, *shrinkA*, and *shrinkB* are ignored.
4043
4038
4044
- %(AvailableConnectorstyles)s
4039
+ Parameters
4040
+ ----------
4045
4041
4042
+ posA, posB : None, tuple, optional (default: None)
4043
+ (x,y) coordinates of arrow tail and arrow head respectively.
4046
4044
4047
- The *arrowstyle* describes how the fancy arrow will be
4048
- drawn. It can be string of the available arrowstyle names,
4049
- with optional comma-separated attributes, or one of the
4050
- ArrowStyle instance. The optional attributes are meant to be
4051
- scaled with the *mutation_scale*. The following arrow styles are
4052
- available.
4045
+ path : None, Path (default: None)
4046
+ :class:`matplotlib.path.Path` instance. If provided, an arrow is
4047
+ drawn along this path and *patchA*, *patchB*, *shrinkA*, and
4048
+ *shrinkB* are ignored.
4053
4049
4054
- %(AvailableArrowstyles)s
4050
+ arrowstyle : str or ArrowStyle, optional (default: 'simple')
4051
+ Describes how the fancy arrow will be
4052
+ drawn. It can be string of the available arrowstyle names,
4053
+ with optional comma-separated attributes, or an
4054
+ :class:`ArrowStyle` instance. The optional attributes are meant to
4055
+ be scaled with the *mutation_scale*. The following arrow styles are
4056
+ available:
4055
4057
4056
- *mutation_scale* : a value with which attributes of arrowstyle
4057
- (e.g., head_length) will be scaled. default=1.
4058
+ %(AvailableArrowstyles)s
4058
4059
4059
- *mutation_aspect* : The height of the rectangle will be
4060
- squeezed by this value before the mutation and the mutated
4061
- box will be stretched by the inverse of it. default=None.
4060
+ arrow_transmuter :
4061
+ Ignored
4062
+
4063
+ connectionstyle : str, ConnectionStyle, or None, optional
4064
+ (default: 'arc3')
4065
+ Describes how *posA* and *posB* are connected. It can be an
4066
+ instance of the :class:`ConnectionStyle` class or a string of the
4067
+ connectionstyle name, with optional comma-separated attributes. The
4068
+ following connection styles are available:
4069
+
4070
+ %(AvailableConnectorstyles)s
4062
4071
4072
+ connector :
4073
+ Ignored
4074
+
4075
+ patchA, patchB : None, Patch, optional (default: None)
4076
+ Head and tail patch respectively. :class:`matplotlib.patch.Patch`
4077
+ instance.
4078
+
4079
+ shrinkA, shrinkB : scalar, optional (default: 2)
4080
+ Shrinking factor of the tail and head of the arrow respectively
4081
+
4082
+ mutation_scale : scalar, optional (default: 1)
4083
+ Value with which attributes of *arrowstyle* (e.g., *head_length*)
4084
+ will be scaled.
4085
+
4086
+ mutation_aspect : None, scalar, optional (default: None)
4087
+ The height of the rectangle will be squeezed by this value before
4088
+ the mutation and the mutated box will be stretched by the inverse
4089
+ of it.
4090
+
4091
+ dpi_cor : scalar, optional (defualt: 1)
4092
+ dpi_cor is currently used for linewidth-related things and shrink
4093
+ factor. Mutation scale is affected by this.
4094
+
4095
+ Notes
4096
+ -----
4063
4097
Valid kwargs are:
4064
4098
%(Patch)s
4065
4099
"""
@@ -4091,28 +4125,39 @@ def __init__(self, posA=None, posB=None,
4091
4125
self ._mutation_aspect = mutation_aspect
4092
4126
4093
4127
self .set_dpi_cor (dpi_cor )
4094
- #self._draw_in_display_coordinate = True
4095
4128
4096
4129
def set_dpi_cor (self , dpi_cor ):
4097
4130
"""
4098
4131
dpi_cor is currently used for linewidth-related things and
4099
4132
shrink factor. Mutation scale is affected by this.
4100
- """
4101
4133
4134
+ Parameters
4135
+ ----------
4136
+ dpi_cor : scalar
4137
+ """
4102
4138
self ._dpi_cor = dpi_cor
4103
4139
self .stale = True
4104
4140
4105
4141
def get_dpi_cor (self ):
4106
4142
"""
4107
4143
dpi_cor is currently used for linewidth-related things and
4108
4144
shrink factor. Mutation scale is affected by this.
4109
- """
4110
4145
4146
+ Returns
4147
+ -------
4148
+ dpi_cor : scalar
4149
+ """
4111
4150
return self ._dpi_cor
4112
4151
4113
4152
def set_positions (self , posA , posB ):
4114
- """ set the begin and end positions of the connecting
4115
- path. Use current value if None.
4153
+ """
4154
+ Set the begin and end positions of the connecting path.
4155
+
4156
+ Parameters
4157
+ ----------
4158
+ posA, posB : None, tuple
4159
+ (x,y) coordinates of arrow tail and arrow head respectively. If
4160
+ `None` use current value.
4116
4161
"""
4117
4162
if posA is not None :
4118
4163
self ._posA_posB [0 ] = posA
@@ -4121,65 +4166,83 @@ def set_positions(self, posA, posB):
4121
4166
self .stale = True
4122
4167
4123
4168
def set_patchA (self , patchA ):
4124
- """ set the begin patch.
4169
+ """
4170
+ Set the tail patch.
4171
+
4172
+ Parameters
4173
+ ----------
4174
+ patchA : Patch
4175
+ :class:`matplotlib.patch.Patch` instance.
4125
4176
"""
4126
4177
self .patchA = patchA
4127
4178
self .stale = True
4128
4179
4129
4180
def set_patchB (self , patchB ):
4130
- """ set the begin patch
4181
+ """
4182
+ Set the head patch.
4183
+
4184
+ Parameters
4185
+ ----------
4186
+ patchB : Patch
4187
+ :class:`matplotlib.patch.Patch` instance.
4131
4188
"""
4132
4189
self .patchB = patchB
4133
4190
self .stale = True
4134
4191
4135
4192
def set_connectionstyle (self , connectionstyle , ** kw ):
4136
4193
"""
4137
- Set the connection style.
4194
+ Set the connection style. Old attributes are forgotten.
4195
+
4196
+ Parameters
4197
+ ----------
4198
+ connectionstyle : None, ConnectionStyle instance, or string
4199
+ Can be a string with connectionstyle name with
4200
+ optional comma-separated attributes, e.g.::
4138
4201
4139
- *connectionstyle* can be a string with connectionstyle name with
4140
- optional comma-separated attributes. Alternatively, the attrs can be
4141
- provided as keywords.
4202
+ set_connectionstyle("arc,angleA=0,armA=30,rad=10")
4142
4203
4143
- set_connectionstyle("arc,angleA=0,armA=30,rad=10")
4144
- set_connectionstyle("arc", angleA=0,armA=30,rad=10)
4204
+ Alternatively, the attributes can be provided as keywords, e.g.::
4145
4205
4146
- Old attrs simply are forgotten.
4206
+ set_connectionstyle("arc", angleA=0,armA=30,rad=10)
4147
4207
4148
- Without argument (or with connectionstyle=None), return
4149
- available styles as a list of strings.
4208
+ Without any arguments (or with `` connectionstyle=None`` ), return
4209
+ available styles as a list of strings.
4150
4210
"""
4151
4211
4152
4212
if connectionstyle is None :
4153
4213
return ConnectionStyle .pprint_styles ()
4154
4214
4155
- if (isinstance (connectionstyle , ConnectionStyle ._Base )
4156
- or callable (connectionstyle )):
4215
+ if (isinstance (connectionstyle , ConnectionStyle ._Base ) or
4216
+ callable (connectionstyle )):
4157
4217
self ._connector = connectionstyle
4158
4218
else :
4159
4219
self ._connector = ConnectionStyle (connectionstyle , ** kw )
4160
4220
self .stale = True
4161
4221
4162
4222
def get_connectionstyle (self ):
4163
4223
"""
4164
- Return the ConnectionStyle instance
4224
+ Return the :class:` ConnectionStyle` instance.
4165
4225
"""
4166
4226
return self ._connector
4167
4227
4168
4228
def set_arrowstyle (self , arrowstyle = None , ** kw ):
4169
4229
"""
4170
- Set the arrow style.
4230
+ Set the arrow style. Old attributes are forgotten. Without arguments
4231
+ (or with ``arrowstyle=None``) returns available box styles as a list of
4232
+ strings.
4171
4233
4172
- *arrowstyle* can be a string with arrowstyle name with optional
4173
- comma-separated attributes. Alternatively, the attrs can
4174
- be provided as keywords.
4234
+ Parameters
4235
+ ----------
4236
+ arrowstyle : None, ArrowStyle, str, optional (default: None)
4237
+ Can be a string with arrowstyle name with optional comma-separated
4238
+ attributes, e.g.::
4175
4239
4176
- set_arrowstyle("Fancy,head_length=0.2")
4177
- set_arrowstyle("fancy", head_length=0.2)
4240
+ set_arrowstyle("Fancy,head_length=0.2")
4178
4241
4179
- Old attrs simply are forgotten.
4242
+ Alternatively attributes can be provided as keywords, e.g.::
4243
+
4244
+ set_arrowstyle("fancy", head_length=0.2)
4180
4245
4181
- Without argument (or with arrowstyle=None), return
4182
- available box styles as a list of strings.
4183
4246
"""
4184
4247
4185
4248
if arrowstyle is None :
@@ -4193,30 +4256,38 @@ def set_arrowstyle(self, arrowstyle=None, **kw):
4193
4256
4194
4257
def get_arrowstyle (self ):
4195
4258
"""
4196
- Return the arrowstyle object
4259
+ Return the arrowstyle object.
4197
4260
"""
4198
4261
return self ._arrow_transmuter
4199
4262
4200
4263
def set_mutation_scale (self , scale ):
4201
4264
"""
4202
4265
Set the mutation scale.
4203
4266
4204
- ACCEPTS: float
4267
+ Parameters
4268
+ ----------
4269
+ scale : scalar
4205
4270
"""
4206
4271
self ._mutation_scale = scale
4207
4272
self .stale = True
4208
4273
4209
4274
def get_mutation_scale (self ):
4210
4275
"""
4211
4276
Return the mutation scale.
4277
+
4278
+ Returns
4279
+ -------
4280
+ scale : scalar
4212
4281
"""
4213
4282
return self ._mutation_scale
4214
4283
4215
4284
def set_mutation_aspect (self , aspect ):
4216
4285
"""
4217
4286
Set the aspect ratio of the bbox mutation.
4218
4287
4219
- ACCEPTS: float
4288
+ Parameters
4289
+ ----------
4290
+ aspect : scalar
4220
4291
"""
4221
4292
self ._mutation_aspect = aspect
4222
4293
self .stale = True
@@ -4229,9 +4300,9 @@ def get_mutation_aspect(self):
4229
4300
4230
4301
def get_path (self ):
4231
4302
"""
4232
- return the path of the arrow in the data coordinate . Use
4303
+ Return the path of the arrow in the data coordinates . Use
4233
4304
get_path_in_displaycoord() method to retrieve the arrow path
4234
- in the display coord .
4305
+ in display coordinates .
4235
4306
"""
4236
4307
_path , fillable = self .get_path_in_displaycoord ()
4237
4308
@@ -4242,7 +4313,7 @@ def get_path(self):
4242
4313
4243
4314
def get_path_in_displaycoord (self ):
4244
4315
"""
4245
- Return the mutated path of the arrow in the display coord
4316
+ Return the mutated path of the arrow in display coordinates.
4246
4317
"""
4247
4318
4248
4319
dpi_cor = self .get_dpi_cor ()
@@ -4260,13 +4331,12 @@ def get_path_in_displaycoord(self):
4260
4331
_path = self .get_transform ().transform_path (self ._path_original )
4261
4332
4262
4333
_path , fillable = self .get_arrowstyle ()(
4263
- _path ,
4264
- self .get_mutation_scale () * dpi_cor ,
4265
- self .get_linewidth () * dpi_cor ,
4266
- self .get_mutation_aspect ()
4267
- )
4334
+ _path ,
4335
+ self .get_mutation_scale () * dpi_cor ,
4336
+ self .get_linewidth () * dpi_cor ,
4337
+ self .get_mutation_aspect ())
4268
4338
4269
- #if not fillable:
4339
+ # if not fillable:
4270
4340
# self._fill = False
4271
4341
4272
4342
return _path , fillable
@@ -4313,7 +4383,7 @@ def draw(self, renderer):
4313
4383
# FIXME : dpi_cor is for the dpi-dependecy of the
4314
4384
# linewidth. There could be room for improvement.
4315
4385
#
4316
- #dpi_cor = renderer.points_to_pixels(1.)
4386
+ # dpi_cor = renderer.points_to_pixels(1.)
4317
4387
self .set_dpi_cor (renderer .points_to_pixels (1. ))
4318
4388
path , fillable = self .get_path_in_displaycoord ()
4319
4389
0 commit comments