30
30
----------
31
31
apex : Tuple[float,float]
32
32
The position of the vertex.
33
- incidence_angle : float, in
34
- For vertices with one incoming line, set to ``None``. For vertices that
35
- form a corner, the angle swept out by the two lines that meet at the
36
- vertex.
37
- corner_angle : float
38
- the internal angle of the corner, where np.pi is a straight line, and 0
33
+ incidence_angle : float, in [-pi, pi]
34
+ For vertices with one incoming line, the orientation of the tangent vector
35
+ to the line at its tip (as returned by `np.arctan2`). For corners (vertices
36
+ with two incoming lines) the orientation of the corner's bisector should be
37
+ used instead. All orientation angles should be computed assuming the line
38
+ or bisector "points" towards the corner's apex.
39
+ corner_angle : float, in [0, pi]
40
+ The internal angle of the corner, where np.pi is a straight line, and 0
39
41
is retracing exactly the way you came. None can be used to signify that
40
42
the line ends there (i.e. no corner).
41
-
42
- Notes
43
- -----
44
- $\pi$ and 0 are equivalent for `corner_angle`. Both $\theta$ and $\pi - \theta$
45
- are equivalent for `incidence_angle` by symmetry.
46
43
"""
47
44
48
45
@@ -726,7 +723,7 @@ def get_stroked_extents(self, markeredgewidth, transform, joinstyle,
726
723
typically defined in points, so it doesn't usually make sense to
727
724
request the stroked extents of a path without transforming it.
728
725
joinstyle : {'miter', 'bevel', 'round'}
729
- How the corner is to be drawn.
726
+ How line corners are to be drawn.
730
727
capstyle : {'butt', 'round', 'projecting'}
731
728
How line ends are to be drawn.
732
729
**kwargs
@@ -742,7 +739,7 @@ def get_stroked_extents(self, markeredgewidth, transform, joinstyle,
742
739
----
743
740
The approach used is simply to notice that the bbox with no marker edge
744
741
must be defined by a corner (control point of the linear parts of path)
745
- or a an extremal point on one of the curved parts of the path.
742
+ or an extremal point on one of the curved parts of the path.
746
743
747
744
For a nonzero marker edge width, because the interior extrema will by
748
745
definition be parallel to the bounding box, we need only check if the
@@ -1209,26 +1206,36 @@ def get_path_collection_extents(
1209
1206
1210
1207
1211
1208
def _vertex_info_from_angles (angle_1 , angle_2 ):
1212
- """
1213
- Gets VertexInfo from direction of lines making up a corner.
1214
-
1215
- This function expects angle_1 and angle_2 (in radians) to be
1216
- the orientation of lines 1 and 2 (arbitrarily chosen to point
1217
- towards the corner where they meet) relative to the coordinate
1218
- system.
1209
+ r"""
1210
+ Gets `.VertexInfo` from direction of lines making up a corner.
1219
1211
1220
1212
Helper function for `.iter_angles`.
1221
1213
1214
+ Parameters
1215
+ ----------
1216
+ angle_1 : float in [-pi, pi]
1217
+ Orientation of the tangent vector of the first line at the corner, if
1218
+ the tangent vector is defined to be oriented pointing along the line
1219
+ towards the corner's apex. See `Examples` for clarification.
1220
+ angle_2 : float
1221
+ Same as *angle_1* but for the other line forming the corner.
1222
+
1222
1223
Returns
1223
1224
-------
1224
1225
incidence_angle : float in [-pi, pi]
1225
- as described in VertexInfo docs
1226
+ as described in `. VertexInfo` docs
1226
1227
corner_angle : float in [0, pi]
1227
- as described in VertexInfo docs
1228
+ as described in `. VertexInfo` docs
1228
1229
1229
1230
Notes
1230
1231
-----
1231
1232
Is necessarily ambiguous if corner_angle is pi.
1233
+
1234
+ Examples
1235
+ --------
1236
+ The only corner in ``Path([[0, 0], [1, 1], [0, 1]])`` would have two lines,
1237
+ (``Path([[0, 0], [1, 1]])`` and ``Path([[1, 1], [0, 1]])``), with angles
1238
+ :math:`\pi/4` and :math:`0`, respectively.
1232
1239
"""
1233
1240
# get "interior" angle between tangents to joined curves' tips
1234
1241
corner_angle = np .abs (angle_1 - angle_2 )
@@ -1248,11 +1255,12 @@ def _vertex_info_from_angles(angle_1, angle_2):
1248
1255
1249
1256
1250
1257
def _stroke_x_overflow (width , phi , theta , joinstyle = 'miter' , capstyle = 'butt' ):
1251
- """
1252
- Computes how far right a stroke of *width* extends past x coordinate of
1253
- vertex.
1258
+ r"""
1259
+ Compute distance a stroke of *width* extends past x coordinate of vertex.
1254
1260
1255
- Assumes the incident lines are both coming from the left.
1261
+ The formulas here only work for corners which "point" in the positive x
1262
+ direction. That is, we assume the incident lines are both coming from the
1263
+ left, and extension is only measured to the right.
1256
1264
1257
1265
Parameters
1258
1266
----------
@@ -1269,14 +1277,23 @@ def _stroke_x_overflow(width, phi, theta, joinstyle='miter', capstyle='butt'):
1269
1277
form a corner, the interior angle swept out by the two lines that meet
1270
1278
at the vertex.
1271
1279
joinstyle : {'miter', 'bevel', 'round'}
1272
- How the corner is to be drawn.
1280
+ How line corners are to be drawn.
1273
1281
capstyle : {'butt', 'round', 'projecting'}
1274
1282
How line ends are to be drawn.
1275
1283
1276
1284
Returns
1277
1285
-------
1278
1286
pad : float
1279
1287
Amount of bbox overflow.
1288
+
1289
+ Notes
1290
+ -----
1291
+ $\pi$ and 0 are equivalent for *theta*. Both $\phi$ and $\pi - \phi$
1292
+ are equivalent for *phi* by symmetry.
1293
+
1294
+ If and only if `.VertexInfo.incidence_angle` is in :math:`[-\pi, \pi]`,
1295
+ then *phi* corresponds to `.VertexInfo.incidence_angle`. *theta* always
1296
+ corresponds to `.VertexInfo.corner_angle`.
1280
1297
"""
1281
1298
if theta is not None and (theta < 0 or theta > np .pi ) \
1282
1299
or phi < 0 or phi > np .pi :
@@ -1309,16 +1326,16 @@ def _stroke_x_overflow(width, phi, theta, joinstyle='miter', capstyle='butt'):
1309
1326
else :
1310
1327
raise ValueError (f"Unknown capstyle: { capstyle } ." )
1311
1328
# the two "same as straight line" cases are NaN limits in the miter formula
1312
- elif np .isclose (theta , 0 ) and np .isclose (phi , 0 ) \
1313
- or np .isclose (theta , np .pi ) and np .isclose (phi , np .pi / 2 ):
1329
+ elif ( np .isclose (theta , 0 ) and np .isclose (phi , 0 )
1330
+ or np .isclose (theta , np .pi ) and np .isclose (phi , np .pi / 2 ) ):
1314
1331
return width / 2
1315
1332
# to calculate the offset for _joinstyle == 'miter', imagine aligning the
1316
1333
# corner so that one line comes in along the negative x-axis, and another
1317
1334
# from above, making an angle $\theta$ with the negative x-axis. The tip of
1318
1335
# the new corner created by the markeredge stroke will be at the point
1319
1336
# where the two outer edge of the markeredge stroke intersect. in the
1320
1337
# orientation described above, the outer edge of the stroke aligned with
1321
- # the x axis will obviously have equation $y = -w/2$ where $w$ is the
1338
+ # the x- axis will obviously have equation $y = -w/2$ where $w$ is the
1322
1339
# markeredgewidth. WLOG, the stroke coming in from above at an angle
1323
1340
# $\theta$ from the negative x-axis will have equation
1324
1341
# $$-(\tan(\theta) x + \frac{w}{2\cos(\theta)}.$$
@@ -1361,7 +1378,7 @@ def _pad_extents_stroked_vertex(extents, vinfo, markeredgewidth, joinstyle,
1361
1378
1362
1379
Parameters
1363
1380
----------
1364
- extents : 4*[ float]
1381
+ extents : (4,) array_like of float
1365
1382
The extents (xmin, ymin, xmax, ymax) of the `~.transforms.Bbox` of the
1366
1383
vertices. Modified in place so that the corner described by *vinfo*
1367
1384
fits into the extents when stroked with a width of *markeredgewidth*.
@@ -1370,13 +1387,13 @@ def _pad_extents_stroked_vertex(extents, vinfo, markeredgewidth, joinstyle,
1370
1387
markeredgewidth : `float`
1371
1388
The width of the stroke being drawn.
1372
1389
joinstyle : {'miter', 'bevel', 'round'}
1373
- How the corner is to be drawn.
1390
+ How line corners are to be drawn.
1374
1391
capstyle : {'butt', 'round', 'projecting'}
1375
1392
How line ends are to be drawn.
1376
1393
1377
1394
Notes
1378
1395
-----
1379
- Implementing by wrapping `._stroke_x_overflow`. This function checks which
1396
+ Implemented by wrapping `._stroke_x_overflow`. This function checks which
1380
1397
direction the corner (or cap) is pointing, then for each side of *extents*
1381
1398
that might need padding, it rotates the corner to point in the positive x
1382
1399
direction and calls `._stroke_x_overflow` to get the padding.
0 commit comments