Noter
Cliquez ici pour télécharger l'exemple de code complet
Lignes avec un effet de chemin coché #
Des coches peuvent être ajoutées le long d'une ligne pour marquer un côté comme barrière à l'aide de
TickedStroke
. Vous pouvez contrôler l'angle, l'espacement et la longueur des graduations.
Les coches apparaîtront également de manière appropriée dans la légende.
![démonstration de lignes avec des tiques](/stable/_images/sphx_glr_lines_with_ticks_demo_001.png)
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import patheffects
# Plot a straight diagonal line with ticked style path
fig, ax = plt.subplots(figsize=(6, 6))
ax.plot([0, 1], [0, 1], label="Line",
path_effects=[patheffects.withTickedStroke(spacing=7, angle=135)])
# Plot a curved line with ticked style path
nx = 101
x = np.linspace(0.0, 1.0, nx)
y = 0.3*np.sin(x*8) + 0.4
ax.plot(x, y, label="Curve", path_effects=[patheffects.withTickedStroke()])
ax.legend()
plt.show()