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

Skip to content

Commit 2f7148f

Browse files
committed
update axes_grid.axislines doc.
svn path=/trunk/matplotlib/; revision=8166
1 parent 207fa99 commit 2f7148f

9 files changed

Lines changed: 400 additions & 9 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import matplotlib.pyplot as plt
2+
import mpl_toolkits.axes_grid.axislines as axislines
3+
4+
def setup_axes(fig, rect):
5+
ax = axislines.Subplot(fig, rect)
6+
fig.add_axes(ax)
7+
8+
ax.set_ylim(-0.1, 1.5)
9+
ax.set_yticks([0, 1])
10+
11+
ax.axis[:].set_visible(False)
12+
13+
ax.axis["x"] = ax.new_floating_axis(1, 0.5)
14+
ax.axis["x"].set_axisline_style("->", size=1.5)
15+
16+
return ax
17+
18+
fig = plt.figure(figsize=(3,2.5))
19+
fig.subplots_adjust(top=0.8)
20+
ax1 = setup_axes(fig, "111")
21+
22+
ax1.axis["x"].set_axis_direction("left")
23+
24+
25+
plt.show()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import matplotlib.pyplot as plt
2+
import mpl_toolkits.axes_grid.axislines as axislines
3+
4+
def setup_axes(fig, rect):
5+
ax = axislines.Subplot(fig, rect)
6+
fig.add_axes(ax)
7+
8+
ax.set_ylim(-0.1, 1.5)
9+
ax.set_yticks([0, 1])
10+
11+
#ax.axis[:].toggle(all=False)
12+
#ax.axis[:].line.set_visible(False)
13+
ax.axis[:].set_visible(False)
14+
15+
ax.axis["x"] = ax.new_floating_axis(1, 0.5)
16+
ax.axis["x"].set_axisline_style("->", size=1.5)
17+
18+
return ax
19+
20+
fig = plt.figure(figsize=(6,2.5))
21+
fig.subplots_adjust(bottom=0.2, top=0.8)
22+
23+
ax1 = setup_axes(fig, "121")
24+
ax1.axis["x"].set_ticklabel_direction("+")
25+
ax1.annotate("ticklabel direction=$+$", (0.5, 0), xycoords="axes fraction",
26+
xytext=(0, -10), textcoords="offset points",
27+
va="top", ha="center")
28+
29+
ax2 = setup_axes(fig, "122")
30+
ax2.axis["x"].set_ticklabel_direction("-")
31+
ax2.annotate("ticklabel direction=$-$", (0.5, 0), xycoords="axes fraction",
32+
xytext=(0, -10), textcoords="offset points",
33+
va="top", ha="center")
34+
35+
36+
plt.show()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import matplotlib.pyplot as plt
2+
import mpl_toolkits.axes_grid.axislines as axislines
3+
4+
def setup_axes(fig, rect):
5+
ax = axislines.Subplot(fig, rect)
6+
fig.add_axes(ax)
7+
8+
ax.set_ylim(-0.1, 1.5)
9+
ax.set_yticks([0, 1])
10+
11+
#ax.axis[:].toggle(all=False)
12+
#ax.axis[:].line.set_visible(False)
13+
ax.axis[:].set_visible(False)
14+
15+
ax.axis["x"] = ax.new_floating_axis(1, 0.5)
16+
ax.axis["x"].set_axisline_style("->", size=1.5)
17+
18+
return ax
19+
20+
fig = plt.figure(figsize=(6,2.5))
21+
fig.subplots_adjust(bottom=0.2, top=0.8)
22+
23+
ax1 = setup_axes(fig, "121")
24+
ax1.axis["x"].label.set_text("Label")
25+
ax1.axis["x"].toggle(ticklabels=False)
26+
ax1.axis["x"].set_axislabel_direction("+")
27+
ax1.annotate("label direction=$+$", (0.5, 0), xycoords="axes fraction",
28+
xytext=(0, -10), textcoords="offset points",
29+
va="top", ha="center")
30+
31+
ax2 = setup_axes(fig, "122")
32+
ax2.axis["x"].label.set_text("Label")
33+
ax2.axis["x"].toggle(ticklabels=False)
34+
ax2.axis["x"].set_axislabel_direction("-")
35+
ax2.annotate("label direction=$-$", (0.5, 0), xycoords="axes fraction",
36+
xytext=(0, -10), textcoords="offset points",
37+
va="top", ha="center")
38+
39+
40+
plt.show()
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import matplotlib.pyplot as plt
2+
import mpl_toolkits.axes_grid.axislines as axislines
3+
4+
def setup_axes(fig, rect):
5+
ax = axislines.Subplot(fig, rect)
6+
fig.add_axes(ax)
7+
8+
ax.set_ylim(-0.1, 1.5)
9+
ax.set_yticks([0, 1])
10+
11+
ax.axis[:].set_visible(False)
12+
13+
ax.axis["x1"] = ax.new_floating_axis(1, 0.3)
14+
ax.axis["x1"].set_axisline_style("->", size=1.5)
15+
16+
ax.axis["x2"] = ax.new_floating_axis(1, 0.7)
17+
ax.axis["x2"].set_axisline_style("->", size=1.5)
18+
19+
return ax
20+
21+
fig = plt.figure(figsize=(6,2.5))
22+
fig.subplots_adjust(bottom=0.2, top=0.8)
23+
24+
ax1 = setup_axes(fig, "121")
25+
ax1.axis["x1"].label.set_text("rotation=0")
26+
ax1.axis["x1"].toggle(ticklabels=False)
27+
28+
ax1.axis["x2"].label.set_text("rotation=10")
29+
ax1.axis["x2"].label.set_rotation(10)
30+
ax1.axis["x2"].toggle(ticklabels=False)
31+
32+
ax1.annotate("label direction=$+$", (0.5, 0), xycoords="axes fraction",
33+
xytext=(0, -10), textcoords="offset points",
34+
va="top", ha="center")
35+
36+
ax2 = setup_axes(fig, "122")
37+
38+
ax2.axis["x1"].set_axislabel_direction("-")
39+
ax2.axis["x2"].set_axislabel_direction("-")
40+
41+
ax2.axis["x1"].label.set_text("rotation=0")
42+
ax2.axis["x1"].toggle(ticklabels=False)
43+
44+
ax2.axis["x2"].label.set_text("rotation=10")
45+
ax2.axis["x2"].label.set_rotation(10)
46+
ax2.axis["x2"].toggle(ticklabels=False)
47+
48+
49+
ax2.annotate("label direction=$-$", (0.5, 0), xycoords="axes fraction",
50+
xytext=(0, -10), textcoords="offset points",
51+
va="top", ha="center")
52+
53+
54+
plt.show()

doc/mpl_toolkits/axes_grid/figures/demo_ticklabel_direction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def setup_axes(fig, rect):
3333
ax.axis["right"].set_axis_direction("left")
3434
ax.axis["top"].set_axis_direction("bottom")
3535

36-
ax.axis["left"].major_ticklabels.set_pad(0)
37-
ax.axis["bottom"].major_ticklabels.set_pad(10)
36+
#ax.axis["left"].major_ticklabels.set_pad(0)
37+
#ax.axis["bottom"].major_ticklabels.set_pad(10)
3838

3939

4040

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import matplotlib.pyplot as plt
2+
import mpl_toolkits.axes_grid.axislines as axislines
3+
4+
fig = plt.figure(figsize=(4,2.5))
5+
ax1 = fig.add_subplot(axislines.Subplot(fig, "111"))
6+
fig.subplots_adjust(right=0.8)
7+
8+
ax1.axis["left"].major_ticklabels.set_axis_direction("top")
9+
ax1.axis["left"].label.set_text("Label")
10+
11+
ax1.axis["right"].label.set_visible(True)
12+
ax1.axis["right"].label.set_text("Label")
13+
ax1.axis["right"].label.set_axis_direction("left")
14+
15+
plt.show()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
import matplotlib.pyplot as plt
3+
import mpl_toolkits.axes_grid.axislines as axislines
4+
5+
def setup_axes(fig, rect):
6+
ax = axislines.Subplot(fig, rect)
7+
fig.add_subplot(ax)
8+
9+
ax.set_yticks([0.2, 0.8])
10+
ax.set_xticks([0.2, 0.8])
11+
12+
return ax
13+
14+
fig = plt.figure(1, figsize=(4, 2))
15+
ax = setup_axes(fig, "111")
16+
17+
ax.axis[:].major_ticks.set_tick_out(True)
18+
19+
plt.show()
20+
21+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
import matplotlib.pyplot as plt
3+
import mpl_toolkits.axes_grid.axislines as axislines
4+
5+
def setup_axes(fig, rect):
6+
ax = axislines.Subplot(fig, rect)
7+
fig.add_subplot(ax)
8+
9+
ax.set_yticks([0.2, 0.8])
10+
ax.set_xticks([0.2, 0.8])
11+
12+
return ax
13+
14+
fig = plt.figure(1, figsize=(5, 2))
15+
fig.subplots_adjust(wspace=0.4, bottom=0.3)
16+
17+
ax1 = setup_axes(fig, "121")
18+
ax1.set_xlabel("X-label")
19+
ax1.set_ylabel("Y-label")
20+
21+
ax1.axis[:].invert_ticklabel_direction()
22+
23+
ax2 = setup_axes(fig, "122")
24+
ax2.set_xlabel("X-label")
25+
ax2.set_ylabel("Y-label")
26+
27+
ax2.axis[:].major_ticks.set_tick_out(True)
28+
29+
plt.show()
30+
31+

0 commit comments

Comments
 (0)