@@ -22,19 +22,29 @@ working with paths and transformations: :doc:`/tutorials/advanced/path_tutorial`
2222mplot3d
2323--------
2424
25-
2625Reinier Heeres has ported John Porter's mplot3d over to the new
2726matplotlib transformations framework, and it is now available as a
2827toolkit mpl_toolkits.mplot3d (which now comes standard with all mpl
2928installs). See :ref: `mplot3d-examples-index ` and
3029:ref: `toolkit_mplot3d-tutorial `
3130
32- .. figure :: ../../gallery/pyplots/images/sphx_glr_whats_new_99_mplot3d_001.png
33- :target: ../../gallery/pyplots/whats_new_99_mplot3d.html
34- :align: center
35- :scale: 50
31+ .. plot ::
32+
33+ from matplotlib import cm
34+ from mpl_toolkits.mplot3d import Axes3D
35+
36+ X = np.arange(-5, 5, 0.25)
37+ Y = np.arange(-5, 5, 0.25)
38+ X, Y = np.meshgrid(X, Y)
39+ R = np.sqrt(X**2 + Y**2)
40+ Z = np.sin(R)
41+
42+ fig = plt.figure()
43+ ax = Axes3D(fig, auto_add_to_figure=False)
44+ fig.add_axes(ax)
45+ ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.viridis)
3646
37- What's New 99 Mplot3d
47+ plt.show()
3848
3949.. _whats-new-axes-grid :
4050
@@ -48,12 +58,49 @@ new mpl installs. See :ref:`axes_grid1-examples-index`,
4858:ref: `axisartist-examples-index `, :ref: `axes_grid1_users-guide-index ` and
4959:ref: `axisartist_users-guide-index `
5060
51- .. figure :: ../../gallery/pyplots/images/sphx_glr_whats_new_99_axes_grid_001.png
52- :target: ../../gallery/pyplots/whats_new_99_axes_grid.html
53- :align: center
54- :scale: 50
61+ .. plot ::
62+
63+ from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
64+
65+
66+ def get_demo_image():
67+ # prepare image
68+ delta = 0.5
69+
70+ extent = (-3, 4, -4, 3)
71+ x = np.arange(-3.0, 4.001, delta)
72+ y = np.arange(-4.0, 3.001, delta)
73+ X, Y = np.meshgrid(x, y)
74+ Z1 = np.exp(-X**2 - Y**2)
75+ Z2 = np.exp(-(X - 1)**2 - (Y - 1)**2)
76+ Z = (Z1 - Z2) * 2
77+
78+ return Z, extent
79+
80+
81+ def get_rgb():
82+ Z, extent = get_demo_image()
83+
84+ Z[Z < 0] = 0.
85+ Z = Z / Z.max()
86+
87+ R = Z[:13, :13]
88+ G = Z[2:, 2:]
89+ B = Z[:13, 2:]
90+
91+ return R, G, B
5592
56- What's New 99 Axes Grid
93+
94+ fig = plt.figure()
95+ ax = RGBAxes(fig, [0.1, 0.1, 0.8, 0.8])
96+
97+ r, g, b = get_rgb()
98+ ax.imshow_rgb(r, g, b, origin="lower")
99+
100+ ax.RGB.set_xlim(0., 9.5)
101+ ax.RGB.set_ylim(0.9, 10.6)
102+
103+ plt.show()
57104
58105.. _whats-new-spine :
59106
@@ -68,9 +115,47 @@ well as "detach" the spine to offset it away from the data. See
68115:doc: `/gallery/ticks_and_spines/spine_placement_demo ` and
69116:class: `matplotlib.spines.Spine `.
70117
71- .. figure :: ../../gallery/pyplots/images/sphx_glr_whats_new_99_spines_001.png
72- :target: ../../gallery/pyplots/whats_new_99_spines.html
73- :align: center
74- :scale: 50
118+ .. plot ::
119+
120+ def adjust_spines(ax, spines):
121+ for loc, spine in ax.spines.items():
122+ if loc in spines:
123+ spine.set_position(('outward', 10)) # outward by 10 points
124+ else:
125+ spine.set_color('none') # don't draw spine
126+
127+ # turn off ticks where there is no spine
128+ if 'left' in spines:
129+ ax.yaxis.set_ticks_position('left')
130+ else:
131+ # no yaxis ticks
132+ ax.yaxis.set_ticks([])
133+
134+ if 'bottom' in spines:
135+ ax.xaxis.set_ticks_position('bottom')
136+ else:
137+ # no xaxis ticks
138+ ax.xaxis.set_ticks([])
139+
140+ fig = plt.figure()
141+
142+ x = np.linspace(0, 2*np.pi, 100)
143+ y = 2*np.sin(x)
144+
145+ ax = fig.add_subplot(2, 2, 1)
146+ ax.plot(x, y)
147+ adjust_spines(ax, ['left'])
148+
149+ ax = fig.add_subplot(2, 2, 2)
150+ ax.plot(x, y)
151+ adjust_spines(ax, [])
152+
153+ ax = fig.add_subplot(2, 2, 3)
154+ ax.plot(x, y)
155+ adjust_spines(ax, ['left', 'bottom'])
156+
157+ ax = fig.add_subplot(2, 2, 4)
158+ ax.plot(x, y)
159+ adjust_spines(ax, ['bottom'])
75160
76- What's New 99 Spines
161+ plt.show()
0 commit comments