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

Commit64d5297

Browse files
Doc: spines arrows example
1 parentb731c29 commit64d5297

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

‎examples/axisartist/demo_axisline_style.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
Axis line styles
44
================
55
6-
This example shows some configurations for axis style.
6+
This example shows some configurations for axis style.
7+
8+
Note: The `mpl_toolkits.axisartist` axes classes may be confusing for new
9+
users. If the only aim is to obtain arrow heads at the ends of the axes,
10+
rather check out the :doc:`/gallery/recipes/centered_spines_with_arrows`
11+
example.
712
"""
813

914
frommpl_toolkits.axisartist.axislinesimportSubplotZero
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
===========================
3+
Centered spines with arrows
4+
===========================
5+
6+
This example shows a way to draw a "math textbook" style plot, where the
7+
spines ("axes lines") are drawn at ``x = 0`` and ``y = 0``, and have arrows at
8+
their ends.
9+
"""
10+
11+
importmatplotlib.pyplotasplt
12+
importnumpyasnp
13+
14+
15+
fig,ax=plt.subplots()
16+
# Move the left and bottom spines to x = 0 and y = 0, respectively.
17+
ax.spines["left"].set_position(("data",0))
18+
ax.spines["bottom"].set_position(("data",0))
19+
# Hide the top and right spines.
20+
ax.spines["top"].set_visible(False)
21+
ax.spines["right"].set_visible(False)
22+
23+
# Draw arrows (as black triangles: ">k"/"^k") at the end of the axes. In each
24+
# case, one of the coordinates (0) is a data coordinate (i.e., y = 0 or x = 0,
25+
# respectively) and the other one (1) is an axes coordinate (i.e., at the very
26+
# right/top of the axes). Also, disable clipping (clip_on=False) as the marker
27+
# actually spills out of the axes.
28+
ax.plot(1,0,">k",transform=ax.get_yaxis_transform(),clip_on=False)
29+
ax.plot(0,1,"^k",transform=ax.get_xaxis_transform(),clip_on=False)
30+
31+
# Some sample data.
32+
x=np.linspace(-0.5,1.,100)
33+
ax.plot(x,np.sin(x*np.pi))
34+
35+
plt.show()
36+

‎examples/ticks_and_spines/spine_placement_demo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
====================
55
66
Adjusting the location and appearance of axis spines.
7+
8+
Note: If you want to obtain arrow heads at the ends of the axes, also check
9+
out the :doc:`/gallery/recipes/centered_spines_with_arrows` example.
710
"""
811
importnumpyasnp
912
importmatplotlib.pyplotasplt

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp