Skip to content

Commit 690177e

Browse files
committed
add demo for axline with transform parameter
1 parent db44748 commit 690177e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

examples/pyplots/axline.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
plt.legend(fontsize=14)
2828
plt.show()
2929

30+
# `~.axes.Axes.axline` can also be used with a `transform` parameter, which
31+
# applies to the point, but not to the slope. This can be useful for drawing
32+
# diagonal grid lines with a fixed slope, which stay in place when the
33+
# plot limits are moved.
34+
35+
for pos in np.linspace(-2, 1, 10):
36+
plt.axline((pos, 0), slope=0.5, color='k', transform=plt.gca().transAxes)
37+
38+
plt.ylim([0, 1])
39+
plt.xlim([0, 1])
40+
plt.show()
41+
3042
#############################################################################
3143
#
3244
# ------------

0 commit comments

Comments
 (0)