@@ -146,26 +146,90 @@ The text color of legend labels can now be set by passing a parameter
146146* ``markeredgecolor ``, which sets the text color of each label to match the
147147 corresponding marker edge color.
148148
149+ .. plot ::
150+
151+ options = ['C3', 'linecolor', 'markerfacecolor', 'markeredgecolor']
152+
153+ fig, axs = plt.subplots(2, 2, constrained_layout=True)
154+ for ax, color in zip(axs.flat, options):
155+ ax.plot([1, 2, 3], marker='o',
156+ color='C0', markerfacecolor='C1', markeredgecolor='C2',
157+ linewidth=3, markersize=10, markeredgewidth=3,
158+ label='a line')
159+
160+ ax.legend(labelcolor=color)
161+ ax.set_title(f'labelcolor={color!r}')
162+
163+ ax.margins(0.1)
164+
149165
150- ``Axes.sharex ``, ``Axes.sharey ``
151- --------------------------------
166+ New ``Axes.sharex ``, ``Axes.sharey `` methods
167+ --------------------------------------------
152168
153- These new methods allow sharing axes *immediately * after creating them. For
154- example, they can be used to selectively link some axes created all together
155- using `~.Figure.subplots `.
169+ These new methods allow sharing axes *immediately * after creating them. Note
170+ that they may *not * be used to share axes after any operation (e.g., drawing)
171+ has occurred on them.
172+
173+ For example, they can be used to selectively link some axes created all
174+ together using `~.Figure.subplot_mosaic `::
175+
176+ fig = plt.figure(constrained_layout=True)
177+ axd = fig.subplot_mosaic([['.', 'histx'], ['histy', 'scat']],
178+ gridspec_kw={'width_ratios': [1, 7],
179+ 'height_ratios': [2, 7]})
180+
181+ axd['histx'].sharex(axd['scat'])
182+ axd['histy'].sharey(axd['scat'])
183+
184+ .. plot ::
156185
157- Note that they may *not * be used to share axes after any operation (e.g.,
158- drawing) has occurred on them.
186+ np.random.seed(0)
187+ x = np.random.random(100) * 100 + 20
188+ y = np.random.random(100) * 50 + 25
189+ c = np.random.random(100) - 0.5
190+
191+ fig = plt.figure(constrained_layout=True)
192+ axd = fig.subplot_mosaic([['.', 'histx'], ['histy', 'scat']],
193+ gridspec_kw={'width_ratios': [1, 7],
194+ 'height_ratios': [2, 7]})
195+
196+ axd['histy'].invert_xaxis()
197+ axd['histx'].sharex(axd['scat'])
198+ axd['histy'].sharey(axd['scat'])
199+
200+ im = axd['scat'].scatter(x, y, c=c, cmap='RdBu', picker=True)
201+ fig.colorbar(im, orientation='horizontal', ax=axd['scat'], shrink=0.8)
202+
203+ axd['histx'].hist(x)
204+ axd['histy'].hist(y, orientation='horizontal')
159205
160206
161207Align labels to Axes edges
162208--------------------------
163209
164- `~.axes.Axes.set_xlabel `, `~.axes.Axes.set_ylabel ` and `.ColorbarBase.set_label `
165- support a parameter ``loc `` for simplified positioning. Supported values are
166- 'left', 'center', or 'right'. The default is controlled via
167- :rc: `xaxis.labelposition ` and :rc: `yaxis.labelposition `; the Colorbar label
168- takes the rcParam based on its orientation.
210+ `~.axes.Axes.set_xlabel `, `~.axes.Axes.set_ylabel ` and
211+ `.ColorbarBase.set_label ` support a parameter ``loc `` for simplified
212+ positioning. For the xlabel, the supported values are 'left', 'center', or
213+ 'right'. For the ylabel, the supported values are 'bottom', 'center', or
214+ 'top'.
215+
216+ The default is controlled via :rc: `xaxis.labelposition ` and
217+ :rc: `yaxis.labelposition `; the Colorbar label takes the rcParam based on its
218+ orientation.
219+
220+ .. plot ::
221+
222+ options = ['left', 'center', 'right']
223+ fig, axs = plt.subplots(len(options), 1, constrained_layout=True)
224+ for ax, loc in zip(axs, options):
225+ ax.plot([1, 2, 3])
226+ ax.set_xlabel(f'xlabel loc={loc!r}', loc=loc)
227+
228+ options = ['bottom', 'center', 'top']
229+ fig, axs = plt.subplots(1, len(options), constrained_layout=True)
230+ for ax, loc in zip(axs, options):
231+ ax.plot([1, 2, 3])
232+ ax.set_ylabel(f'ylabel loc={loc!r}', loc=loc)
169233
170234
171235Offset text is now set to the top when using ``axis.tick_top() ``
@@ -185,6 +249,13 @@ which means to use auto-positioning. If a value is supplied (i.e. the pre-3.0
185249default was ``y=1.0 ``) then auto-positioning is turned off. This can also be
186250set with the new rcParameter :rc: `axes.titley `.
187251
252+ .. plot ::
253+
254+ fig, axs = plt.subplots(1, 2, constrained_layout=True, figsize=(5, 2))
255+ axs[0].set_title('y=0.7\n $\s um_{j_n} x_j$', y=0.7)
256+ axs[1].set_title('y=None\n $\s um_{j_n} x_j$')
257+ plt.show()
258+
188259
189260Dates now use a modern epoch
190261----------------------------
@@ -213,6 +284,32 @@ conversion (using the new epoch) is::
213284tight_layout now supports suptitle
214285----------------------------------
215286
287+ Previous versions did not consider `.Figure.suptitle `, and so it may overlap
288+ with other artists after calling `~.Figure.tight_layout `:
289+
290+ .. plot ::
291+
292+ fig, axs = plt.subplots(1, 3)
293+ for i, ax in enumerate(axs):
294+ ax.plot([1, 2, 3])
295+ ax.set_title(f'Axes {i}')
296+
297+ t = fig.suptitle('suptitle')
298+ t.set_in_layout(False)
299+ fig.tight_layout()
300+
301+ From now on, the ``suptitle `` will be considered:
302+
303+ .. plot ::
304+
305+ fig, axs = plt.subplots(1, 3)
306+ for i, ax in enumerate(axs):
307+ ax.plot([1, 2, 3])
308+ ax.set_title(f'Axes {i}')
309+
310+ fig.suptitle('suptitle')
311+ fig.tight_layout()
312+
216313
217314Allow tick formatters to be set with str or function inputs
218315-----------------------------------------------------------
@@ -360,6 +457,26 @@ ratios as a 3-tuple of X:Y:Z. The default aspect ratio is 4:4:3.
3604573D axes now support minor ticks
361458~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
362459
460+ .. plot ::
461+ :include-source: True
462+
463+ ax = plt.figure().add_subplot(projection='3d')
464+
465+ ax.scatter([0, 1, 2], [1, 3, 5], [30, 50, 70])
466+
467+ ax.set_xticks([0.25, 0.75, 1.25, 1.75], minor=True)
468+ ax.set_xticklabels(['a', 'b', 'c', 'd'], minor=True)
469+
470+ ax.set_yticks([1.5, 2.5, 3.5, 4.5], minor=True)
471+ ax.set_yticklabels(['A', 'B', 'C', 'D'], minor=True)
472+
473+ ax.set_zticks([35, 45, 55, 65], minor=True)
474+ ax.set_zticklabels([r'$\a lpha$', r'$\b eta$', r'$\d elta$', r'$\g amma$'],
475+ minor=True)
476+
477+ ax.tick_params(which='major', color='C0', labelcolor='C0', width=5)
478+ ax.tick_params(which='minor', color='C1', labelcolor='C1', width=3)
479+
363480Home/Forward/Backward buttons now work with 3D axes
364481~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
365482
0 commit comments