Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd42384d

Browse files
authored
Merge pull request#29625 from meeseeksmachine/auto-backport-of-pr-29622-on-v3.10.x
2 parents9f74bf3 +1af4b2e commitd42384d

File tree

1 file changed

+17
-13
lines changed
  • galleries/examples/lines_bars_and_markers

1 file changed

+17
-13
lines changed

‎galleries/examples/pyplots/axline.pyrenamed to‎galleries/examples/lines_bars_and_markers/axline.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
sigmoid function.
1010
1111
`~.axes.Axes.axline` draws infinite straight lines in arbitrary directions.
12+
13+
.. redirect-from:: /gallery/pyplot/axline
1214
"""
1315

1416
importmatplotlib.pyplotasplt
@@ -17,28 +19,28 @@
1719
t=np.linspace(-10,10,100)
1820
sig=1/ (1+np.exp(-t))
1921

20-
plt.axhline(y=0,color="black",linestyle="--")
21-
plt.axhline(y=0.5,color="black",linestyle=":")
22-
plt.axhline(y=1.0,color="black",linestyle="--")
23-
plt.axvline(color="grey")
24-
plt.axline((0,0.5),slope=0.25,color="black",linestyle=(0, (5,5)))
25-
plt.plot(t,sig,linewidth=2,label=r"$\sigma(t) = \frac{1}{1 + e^{-t}}$")
26-
plt.xlim(-10,10)
27-
plt.xlabel("t")
28-
plt.legend(fontsize=14)
22+
fig,ax=plt.subplots()
23+
ax.axhline(y=0,color="black",linestyle="--")
24+
ax.axhline(y=0.5,color="black",linestyle=":")
25+
ax.axhline(y=1.0,color="black",linestyle="--")
26+
ax.axvline(color="grey")
27+
ax.axline((0,0.5),slope=0.25,color="black",linestyle=(0, (5,5)))
28+
ax.plot(t,sig,linewidth=2,label=r"$\sigma(t) = \frac{1}{1 + e^{-t}}$")
29+
ax.set(xlim=(-10,10),xlabel="t")
30+
ax.legend(fontsize=14)
2931
plt.show()
3032

3133
# %%
32-
# `~.axes.Axes.axline` can also be used with a``transform`` parameter, which
34+
# `~.axes.Axes.axline` can also be used with a*transform* parameter, which
3335
# applies to the point, but not to the slope. This can be useful for drawing
3436
# diagonal grid lines with a fixed slope, which stay in place when the
3537
# plot limits are moved.
3638

39+
fig,ax=plt.subplots()
3740
forposinnp.linspace(-2,1,10):
38-
plt.axline((pos,0),slope=0.5,color='k',transform=plt.gca().transAxes)
41+
ax.axline((pos,0),slope=0.5,color='k',transform=ax.transAxes)
3942

40-
plt.ylim([0,1])
41-
plt.xlim([0,1])
43+
ax.set(xlim=(0,1),ylim=(0,1))
4244
plt.show()
4345

4446
# %%
@@ -57,3 +59,5 @@
5759
#
5860
# `~.Axes.axhspan`, `~.Axes.axvspan` draw rectangles that span the Axes in one
5961
# direction and are bounded in the other direction.
62+
#
63+
# .. tags:: component: annotation

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp