|
373 | 373 | # `~matplotlib.figure.Figure.supxlabel` and `~matplotlib.figure.Figure.supylabel`, |
374 | 374 | # these labels are aligned between gridspec edges rather than figure edges. |
375 | 375 | # #. Supporting five sharing "levels". These values can be passed to `sharex`, |
376 | | -# `sharey`, or `share`, or assigned to :rcraw:`subplots.share`. The levels |
377 | | -# are defined as follows: |
| 376 | +# `sharey`, or `share`, or assigned to :rcraw:`subplots.share`. |
| 377 | +# UltraPlot supports five explicit sharing levels plus ``'auto'``. |
| 378 | +# The levels are defined as follows: |
378 | 379 | # |
379 | 380 | # * ``False`` or ``0``: Axis sharing is disabled. |
380 | 381 | # * ``'labels'``, ``'labs'``, or ``1``: Axis labels are shared, but nothing else. |
|
384 | 385 | # in the same row or column of the :class:`~ultraplot.gridspec.GridSpec`; a space |
385 | 386 | # or empty plot will add the labels, but not break the limit sharing. See below |
386 | 387 | # for a more complex example. |
| 388 | +# * ``'limits'``, ``'lims'``, or ``2``: As above, plus share limits/scales/ticks. |
| 389 | +# * ``True`` or ``3``: As above, plus hide inner tick labels. |
| 390 | +# * ``'all'`` or ``4``: As above, plus share limits across the full subplot grid. |
| 391 | +# * ``'auto'`` (default): Start from level ``3`` and only share compatible axes. |
| 392 | +# This suppresses warnings for mixed axis families (e.g., cartesian + polar). |
| 393 | +# |
| 394 | +# Explicit sharing levels still force sharing attempts and may warn when |
| 395 | +# incompatible axes are encountered. |
387 | 396 | # |
388 | 397 | # The below examples demonstrate the effect of various axis and label sharing |
389 | 398 | # settings on the appearance of several subplot grids. |
|
422 | 431 | import ultraplot as uplt |
423 | 432 | import numpy as np |
424 | 433 |
|
| 434 | +# The default `share='auto'` keeps incompatible axis families unshared. |
| 435 | +fig, axs = uplt.subplots(ncols=2, proj=("cart", "polar")) |
| 436 | +x = np.linspace(0, 2 * np.pi, 100) |
| 437 | +axs[0].plot(x, np.sin(x)) |
| 438 | +axs[1].plot(x, np.abs(np.sin(2 * x))) |
| 439 | +axs.format( |
| 440 | + suptitle="Auto sharing with mixed cartesian and polar axes", |
| 441 | + title=("cartesian", "polar"), |
| 442 | +) |
| 443 | + |
| 444 | +# %% |
| 445 | +import ultraplot as uplt |
| 446 | +import numpy as np |
| 447 | + |
425 | 448 | state = np.random.RandomState(51423) |
426 | 449 |
|
427 | 450 | # Plots with minimum and maximum sharing settings |
|
0 commit comments