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

Skip to content

Commit 4b147b4

Browse files
committed
axes_grid: floating_axis support added
svn path=/trunk/matplotlib/; revision=7233
1 parent 55b8834 commit 4b147b4

9 files changed

Lines changed: 994 additions & 463 deletions

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2009-06-24 axes_grid: floating axis support added. - JJL
2+
13
2009-06-14 Add new command line options to backend_driver.py to support
24
running only some directories of tests - JKS
35

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
"""
2+
A floating axes for curvelinear grid.
3+
.
4+
"""
5+
6+
7+
def curvelinear_test2(fig):
8+
"""
9+
polar projection, but in a rectangular box.
10+
"""
11+
import numpy as np
12+
import mpl_toolkits.axes_grid.angle_helper as angle_helper
13+
from matplotlib.projections import PolarAxes
14+
from matplotlib.transforms import Affine2D
15+
16+
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
17+
18+
from mpl_toolkits.axes_grid.grid_helper_curvelinear import GridHelperCurveLinear
19+
20+
# see demo_curvelinear_grid.py for details
21+
tr = Affine2D().scale(np.pi/180., 1.) + PolarAxes.PolarTransform()
22+
23+
extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
24+
lon_cycle = 360,
25+
lat_cycle = None,
26+
lon_minmax = None,
27+
lat_minmax = (0, np.inf),
28+
)
29+
30+
grid_locator1 = angle_helper.LocatorDMS(12)
31+
32+
tick_formatter1 = angle_helper.FormatterDMS()
33+
34+
grid_helper = GridHelperCurveLinear(tr,
35+
extreme_finder=extreme_finder,
36+
grid_locator1=grid_locator1,
37+
tick_formatter1=tick_formatter1
38+
)
39+
40+
41+
ax1 = SubplotHost(fig, 1, 1, 1, grid_helper=grid_helper)
42+
43+
# make ticklabels of right and top axis visible.
44+
for axis in ax1.axis.values():
45+
axis.toggle(all=False)
46+
47+
fig.add_subplot(ax1)
48+
49+
# Now creates floating axis
50+
51+
grid_helper = ax1.get_grid_helper()
52+
# floating axis whose first coordinate (theta) is fixed at 60
53+
ax1.axis["lat"] = axis = grid_helper.new_floating_axis(0, 60, axes=ax1)
54+
axis.label.set_text(r"$\theta = 60^{\circ}$")
55+
axis.label.set_visible(True)
56+
57+
# floating axis whose second coordinate (r) is fixed at 6
58+
ax1.axis["lon"] = axis = grid_helper.new_floating_axis(1, 6, axes=ax1)
59+
axis.label.set_text(r"$r = 6$")
60+
61+
ax1.set_aspect(1.)
62+
ax1.set_xlim(-5, 12)
63+
ax1.set_ylim(-5, 10)
64+
65+
ax1.grid(True)
66+
67+
if __name__ == "__main__":
68+
import matplotlib.pyplot as plt
69+
fig = plt.figure(1, figsize=(5, 5))
70+
fig.clf()
71+
72+
curvelinear_test2(fig)
73+
74+
plt.draw()
75+
plt.show()
76+
77+

examples/axes_grid/scatter_hist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@
5656
axHisty.set_xticks([0, 50, 100])
5757

5858
plt.draw()
59-
#plt.show()
60-
plt.savefig("a.pdf")
59+
plt.show()
60+
#plt.savefig("a.pdf")

examples/axes_grid/simple_axisline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
new_axisline = ax.get_grid_helper().new_fixed_axis
3030

3131
ax.axis["right2"] = new_axisline(loc="right",
32-
offset=offset)
32+
offset=offset,
33+
axes=ax)
3334
ax.axis["right2"].label.set_text("Label Y2")
3435

3536
ax.plot([-2,3,2])

0 commit comments

Comments
 (0)