@@ -22,8 +22,8 @@ The `.Figure` class has a provisional method to generate complex grids of named
22
22
:include-source: True
23
23
24
24
axd = plt.figure(constrained_layout=True).subplot_mosaic(
25
- [["Top", "Top", "Edge" ],
26
- ["Left", ".", "Edge" ]]
25
+ [['.', 'histx' ],
26
+ ['histy', 'scat' ]]
27
27
)
28
28
for k, ax in axd.items():
29
29
ax.text(0.5, 0.5, k,
@@ -343,16 +343,45 @@ generated and used. For a function a `~.ticker.FuncFormatter` is automatically
343
343
generated and used. In other words,
344
344
::
345
345
346
- ax.xaxis.set_major_formatter('price: {x:02} ')
347
- ax.xaxis.set_minor_formatter(lambda x, pos: 'low' if x < 2 else 'high' )
346
+ ax.xaxis.set_major_formatter('{x} km ')
347
+ ax.xaxis.set_minor_formatter(lambda x, pos: str(x-5) )
348
348
349
349
are shortcuts for::
350
350
351
351
import matplotlib.ticker as mticker
352
352
353
- ax.xaxis.set_major_formatter(mticker.StrMethodFormatter('price: {x:02} '))
353
+ ax.xaxis.set_major_formatter(mticker.StrMethodFormatter('{x} km '))
354
354
ax.xaxis.set_minor_formatter(
355
- mticker.FuncFormatter(lambda x, pos: 'low' if x < 2 else 'high'))
355
+ mticker.FuncFormatter(lambda x, pos: str(x-5))
356
+
357
+ .. plot ::
358
+
359
+ from matplotlib import ticker
360
+
361
+ titles = ["'{x} km'", "lambda x, pos: str(x-5)"]
362
+ formatters = ['{x} km', lambda x, pos: str(x-5)]
363
+
364
+ fig, axs = plt.subplots(2, 1, figsize=(8, 2), constrained_layout=True)
365
+
366
+ for ax, title, formatter in zip(axs, titles, formatters):
367
+ # only show the bottom spine
368
+ ax.yaxis.set_major_locator(ticker.NullLocator())
369
+ for spine in ['top', 'left', 'right']:
370
+ ax.spines[spine].set_visible(False)
371
+
372
+ # define tick positions
373
+ ax.xaxis.set_major_locator(ticker.MultipleLocator(1.00))
374
+ ax.xaxis.set_minor_locator(ticker.MultipleLocator(0.25))
375
+
376
+ ax.tick_params(which='major', width=1.00, length=5)
377
+ ax.tick_params(which='minor', width=0.75, length=2.5, labelsize=10)
378
+ ax.set_xlim(0, 5)
379
+ ax.set_ylim(0, 1)
380
+ ax.text(0.0, 0.2, f'ax.xaxis.set_major_formatter({title})',
381
+ transform=ax.transAxes, fontsize=14, fontname='Monospace',
382
+ color='tab:blue')
383
+
384
+ ax.xaxis.set_major_formatter(formatter)
356
385
357
386
358
387
Setting axes box aspect
@@ -450,9 +479,10 @@ and ``sum(x) > 1``, then an error is raised.
450
479
ax[0, 1].pie(x, autopct='%1.2f%%', labels=label(x), normalize=True)
451
480
ax[0, 1].set_title('normalize=True')
452
481
453
- # For the purposes of keeping the documentation build warning-free, and
454
- # future proof for when the deprecation is made permanent, we pass
455
- # *normalize * here explicitly anyway.
482
+ # This is supposed to show the 'old' behavior of not passing *normalize *
483
+ # explicitly, but for the purposes of keeping the documentation build
484
+ # warning-free, and future proof for when the deprecation is made
485
+ # permanent, we pass *normalize * here explicitly anyway.
456
486
ax[1, 0].pie(x, autopct='%1.2f%%', labels=label(x), normalize=False)
457
487
ax[1, 0].set_title('normalize unspecified\n sum(x) < 1')
458
488
ax[1, 1].pie(x * 10, autopct='%1.2f%%', labels=label(x * 10),
0 commit comments