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

Skip to content

Commit a812352

Browse files
authored
Merge pull request #25394 from oscargus/patheffectsdocs2
[DOC] Clarify how to change side of the TickedStroke ticks
2 parents bc28efb + c98896b commit a812352

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

galleries/examples/misc/tickedstroke_demo.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
draws a path with a ticked style. The spacing, length, and angle of
1414
ticks can be controlled.
1515
16-
See also the :doc:`contour demo example
17-
</gallery/lines_bars_and_markers/lines_with_ticks_demo>`.
16+
See also the :doc:`/gallery/lines_bars_and_markers/lines_with_ticks_demo` example.
1817
19-
See also the :doc:`contours in optimization example
20-
</gallery/images_contours_and_fields/contours_in_optimization_demo>`.
18+
See also the :doc:`/gallery/images_contours_and_fields/contours_in_optimization_demo`
19+
example.
2120
"""
2221

2322
import matplotlib.pyplot as plt
@@ -104,3 +103,20 @@
104103
ax.set_ylim(0, 4)
105104

106105
plt.show()
106+
107+
# %%
108+
# Direction/side of the ticks
109+
# ===========================
110+
#
111+
# To change which side of the line the ticks are drawn, change the sign of the angle.
112+
113+
fig, ax = plt.subplots(figsize=(6, 6))
114+
line_x = line_y = [0, 1]
115+
ax.plot(line_x, line_y, label="Line",
116+
path_effects=[patheffects.withTickedStroke(spacing=7, angle=135)])
117+
118+
ax.plot(line_x, line_y, label="Opposite side",
119+
path_effects=[patheffects.withTickedStroke(spacing=7, angle=-135)])
120+
121+
ax.legend()
122+
plt.show()

lib/matplotlib/patheffects.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,7 @@ class TickedStroke(AbstractPathEffect):
386386
387387
This line style is sometimes referred to as a hatched line.
388388
389-
See also the :doc:`contour demo example
390-
</gallery/lines_bars_and_markers/lines_with_ticks_demo>`.
391-
392-
See also the :doc:`contours in optimization example
393-
</gallery/images_contours_and_fields/contours_in_optimization_demo>`.
389+
See also the :doc:`/gallery/misc/tickedstroke_demo` example.
394390
"""
395391

396392
def __init__(self, offset=(0, 0),
@@ -407,7 +403,8 @@ def __init__(self, offset=(0, 0),
407403
The angle between the path and the tick in degrees. The angle
408404
is measured as if you were an ant walking along the curve, with
409405
zero degrees pointing directly ahead, 90 to your left, -90
410-
to your right, and 180 behind you.
406+
to your right, and 180 behind you. To change side of the ticks,
407+
change sign of the angle.
411408
length : float, default: 1.414
412409
The length of the tick relative to spacing.
413410
Recommended length = 1.414 (sqrt(2)) when angle=45, length=1.0

0 commit comments

Comments
 (0)