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

Skip to content

Commit 748476e

Browse files
committed
add doc/mpl_toolkits/axes_grid/figures/simple_axis_pad.py and deleted unsed simple_axis_direction02.py
svn path=/trunk/matplotlib/; revision=8169
1 parent 0f81280 commit 748476e

2 files changed

Lines changed: 112 additions & 21 deletions

File tree

doc/mpl_toolkits/axes_grid/figures/simple_axis_direction02.py

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
2+
3+
import numpy as np
4+
import mpl_toolkits.axes_grid.angle_helper as angle_helper
5+
import mpl_toolkits.axes_grid.grid_finder as grid_finder
6+
from matplotlib.projections import PolarAxes
7+
from matplotlib.transforms import Affine2D
8+
9+
import mpl_toolkits.axes_grid.axislines as axislines
10+
11+
from mpl_toolkits.axes_grid.grid_helper_curvelinear import GridHelperCurveLinear
12+
13+
14+
def setup_axes(fig, rect):
15+
"""
16+
polar projection, but in a rectangular box.
17+
"""
18+
19+
# see demo_curvelinear_grid.py for details
20+
tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
21+
22+
extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
23+
lon_cycle = 360,
24+
lat_cycle = None,
25+
lon_minmax = None,
26+
lat_minmax = (0, np.inf),
27+
)
28+
29+
grid_locator1 = angle_helper.LocatorDMS(12)
30+
grid_locator2 = grid_finder.MaxNLocator(5)
31+
32+
tick_formatter1 = angle_helper.FormatterDMS()
33+
34+
grid_helper = GridHelperCurveLinear(tr,
35+
extreme_finder=extreme_finder,
36+
grid_locator1=grid_locator1,
37+
grid_locator2=grid_locator2,
38+
tick_formatter1=tick_formatter1
39+
)
40+
41+
42+
ax1 = axislines.Subplot(fig, rect, grid_helper=grid_helper)
43+
#ax1.axis[:].toggle(all=False)
44+
ax1.axis[:].set_visible(False)
45+
46+
fig.add_subplot(ax1)
47+
48+
ax1.set_aspect(1.)
49+
ax1.set_xlim(-5, 12)
50+
ax1.set_ylim(-5, 10)
51+
52+
#ax1.grid(True)
53+
54+
return ax1
55+
56+
57+
def add_floating_axis1(ax1):
58+
ax1.axis["lat"] = axis = ax1.new_floating_axis(0, 30)
59+
axis.label.set_text(r"$\theta = 30^{\circ}$")
60+
axis.label.set_visible(True)
61+
62+
return axis
63+
64+
65+
def add_floating_axis2(ax1):
66+
ax1.axis["lon"] = axis = ax1.new_floating_axis(1, 6)
67+
axis.label.set_text(r"$r = 6$")
68+
axis.label.set_visible(True)
69+
70+
return axis
71+
72+
73+
import matplotlib.pyplot as plt
74+
fig = plt.figure(1, figsize=(9, 3.))
75+
fig.clf()
76+
fig.subplots_adjust(left=0.01, right=0.99, bottom=0.01, top=0.99,
77+
wspace=0.01, hspace=0.01)
78+
79+
80+
def ann(ax1, d):
81+
if plt.rcParams["text.usetex"]:
82+
d = d.replace("_", r"\_")
83+
84+
ax1.annotate(d, (0.5, 1), (5, -5),
85+
xycoords="axes fraction", textcoords="offset points",
86+
va="top", ha="center")
87+
88+
ax1 = setup_axes(fig, rect=141)
89+
axis = add_floating_axis1(ax1)
90+
ann(ax1, r"default")
91+
92+
ax1 = setup_axes(fig, rect=142)
93+
axis = add_floating_axis1(ax1)
94+
axis.major_ticklabels.set_pad(10)
95+
ann(ax1, r"ticklabels.set_pad(10)")
96+
97+
ax1 = setup_axes(fig, rect=143)
98+
axis = add_floating_axis1(ax1)
99+
axis.label.set_pad(20)
100+
ann(ax1, r"label.set_pad(20)")
101+
102+
ax1 = setup_axes(fig, rect=144)
103+
axis = add_floating_axis1(ax1)
104+
axis.major_ticks.set_tick_out(True)
105+
ann(ax1, "ticks.set_tick_out(True)")
106+
107+
108+
#ax1.axis["bottom"].toggle(all=True)
109+
110+
plt.show()
111+
112+

0 commit comments

Comments
 (0)