Skip to content

Commit 8e2973d

Browse files
authored
fix links to apply_norm (#423)
1 parent f8fb44b commit 8e2973d

3 files changed

Lines changed: 44 additions & 26 deletions

File tree

docs/2dplots.py

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@
7777
# setting and the :ref:`user guide <ug_1dstd>`).
7878

7979
# %%
80-
import ultraplot as uplt
8180
import numpy as np
8281

82+
import ultraplot as uplt
83+
8384
# Sample data
8485
state = np.random.RandomState(51423)
8586
x = y = np.array([-10, -5, 0, 5, 10])
@@ -110,9 +111,10 @@
110111
axs[3].contourf(xedges, yedges, data)
111112

112113
# %%
113-
import ultraplot as uplt
114114
import numpy as np
115115

116+
import ultraplot as uplt
117+
116118
# Sample data
117119
cmap = "turku_r"
118120
state = np.random.RandomState(51423)
@@ -184,9 +186,9 @@
184186
# `~pint.UnitRegistry.setup_matplotlib` so that the axes become unit-aware.
185187

186188
# %%
187-
import xarray as xr
188189
import numpy as np
189190
import pandas as pd
191+
import xarray as xr
190192

191193
# DataArray
192194
state = np.random.RandomState(51423)
@@ -261,13 +263,14 @@
261263
# ``diverging=True``, ``cyclic=True``, or ``qualitative=True`` to any plotting
262264
# command. If the colormap type is not explicitly specified, `sequential` is
263265
# used with the default linear normalizer when data is strictly positive
264-
# or negative, and `diverging` is used with the :ref:`diverging normalizer <ug_norm>`
266+
# or negative, and `diverging` is used with the :ref:`diverging normalizer <ug_apply_norm>`
265267
# when the data limits or colormap levels cross zero (see :ref:`below <ug_autonorm>`).
266268

267269
# %%
268-
import ultraplot as uplt
269270
import numpy as np
270271

272+
import ultraplot as uplt
273+
271274
# Sample data
272275
N = 18
273276
state = np.random.RandomState(51423)
@@ -294,9 +297,10 @@
294297
uplt.rc.reset()
295298

296299
# %%
297-
import ultraplot as uplt
298300
import numpy as np
299301

302+
import ultraplot as uplt
303+
300304
# Sample data
301305
N = 20
302306
state = np.random.RandomState(51423)
@@ -322,9 +326,10 @@
322326
colorbar="b",
323327
)
324328

325-
import ultraplot as uplt
326329
import numpy as np
327330

331+
import ultraplot as uplt
332+
328333
# Sample data
329334
N = 20
330335
state = np.random.RandomState(51423)
@@ -347,7 +352,7 @@
347352
# Special normalizers
348353
# -------------------
349354
#
350-
# UltraPlot includes two new :ref:`"continuous" normalizers <ug_norm>`. The
355+
# UltraPlot includes two new :ref:`"continuous" normalizers <ug_apply_norm>`. The
351356
# `~ultraplot.colors.SegmentedNorm` normalizer provides even color gradations with respect
352357
# to index for an arbitrary monotonically increasing or decreasing list of levels. This
353358
# is automatically applied if you pass unevenly spaced `levels` to a plotting command,
@@ -372,9 +377,10 @@
372377
# affect the interpretation of different datasets.
373378

374379
# %%
375-
import ultraplot as uplt
376380
import numpy as np
377381

382+
import ultraplot as uplt
383+
378384
# Sample data
379385
state = np.random.RandomState(51423)
380386
data = 11 ** (2 * state.rand(20, 20).cumsum(axis=0) / 7)
@@ -395,9 +401,10 @@
395401
)
396402
ax.format(title=norm.title() + " normalizer")
397403
# %%
398-
import ultraplot as uplt
399404
import numpy as np
400405

406+
import ultraplot as uplt
407+
401408
# Sample data
402409
state = np.random.RandomState(51423)
403410
data1 = (state.rand(20, 20) - 0.485).cumsum(axis=1).cumsum(axis=0)
@@ -434,7 +441,7 @@
434441
# commands (e.g., :func:`~ultraplot.axes.PlotAxes.contourf`, :func:`~ultraplot.axes.PlotAxes.pcolor`).
435442
# This is analogous to `matplotlib.colors.BoundaryNorm`, except
436443
# `~ultraplot.colors.DiscreteNorm` can be paired with arbitrary
437-
# continuous normalizers specified by `norm` (see :ref:`above <ug_norm>`).
444+
# continuous normalizers specified by `norm` (see :ref:`above <ug_apply_norm>`).
438445
# Discrete color levels can help readers discern exact numeric values and
439446
# tend to reveal qualitative structure in the data. `~ultraplot.colors.DiscreteNorm`
440447
# also repairs the colormap end-colors by ensuring the following conditions are met:
@@ -463,9 +470,10 @@
463470
# the zero level (useful for single-color :func:`~ultraplot.axes.PlotAxes.contour` plots).
464471

465472
# %%
466-
import ultraplot as uplt
467473
import numpy as np
468474

475+
import ultraplot as uplt
476+
469477
# Sample data
470478
state = np.random.RandomState(51423)
471479
data = 10 + state.normal(0, 1, size=(33, 33)).cumsum(axis=0).cumsum(axis=1)
@@ -485,9 +493,10 @@
485493
axs[2].format(title="Imshow plot\ndiscrete=False (default)", yformatter="auto")
486494

487495
# %%
488-
import ultraplot as uplt
489496
import numpy as np
490497

498+
import ultraplot as uplt
499+
491500
# Sample data
492501
state = np.random.RandomState(51423)
493502
data = (20 * (state.rand(20, 20) - 0.4).cumsum(axis=0).cumsum(axis=1)) % 360
@@ -547,7 +556,7 @@
547556
# the 2D :class:`~ultraplot.axes.PlotAxes` commands will apply the diverging colormap
548557
# :rc:`cmap.diverging` (rather than :rc:`cmap.sequential`) and the diverging
549558
# normalizer `~ultraplot.colors.DivergingNorm` (rather than :class:`~matplotlib.colors.Normalize`
550-
# -- see :ref:`above <ug_norm>`) if the following conditions are met:
559+
# -- see :ref:`above <ug_apply_norm>`) if the following conditions are met:
551560
#
552561
# #. If discrete levels are enabled (see :ref:`above <ug_discrete>`) and the
553562
# level list includes at least 2 negative and 2 positive values.
@@ -560,9 +569,10 @@
560569
# setting :rcraw:`cmap.autodiverging` to ``False``.
561570

562571
# %%
563-
import ultraplot as uplt
564572
import numpy as np
565573

574+
import ultraplot as uplt
575+
566576
N = 20
567577
state = np.random.RandomState(51423)
568578
data = N * 2 + (state.rand(N, N) - 0.45).cumsum(axis=0).cumsum(axis=1) * 10
@@ -605,9 +615,10 @@
605615
# command documentation for details.
606616

607617
# %%
608-
import ultraplot as uplt
609-
import pandas as pd
610618
import numpy as np
619+
import pandas as pd
620+
621+
import ultraplot as uplt
611622

612623
# Sample data
613624
state = np.random.RandomState(51423)
@@ -663,10 +674,11 @@
663674
# `~ultraplot.axes.CartesianAxes`.
664675

665676
# %%
666-
import ultraplot as uplt
667677
import numpy as np
668678
import pandas as pd
669679

680+
import ultraplot as uplt
681+
670682
# Covariance data
671683
state = np.random.RandomState(51423)
672684
data = state.normal(size=(10, 10)).cumsum(axis=0)

docs/colorbars_legends.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,10 @@
7878
# complex arrangements of subplots, colorbars, and legends.
7979

8080
# %%
81-
import ultraplot as uplt
8281
import numpy as np
8382

83+
import ultraplot as uplt
84+
8485
state = np.random.RandomState(51423)
8586
fig = uplt.figure(share=False, refwidth=2.3)
8687

@@ -183,9 +184,10 @@
183184
)
184185

185186
# %%
186-
import ultraplot as uplt
187187
import numpy as np
188188

189+
import ultraplot as uplt
190+
189191
N = 10
190192
state = np.random.RandomState(51423)
191193
fig, axs = uplt.subplots(
@@ -232,9 +234,10 @@
232234
# and the tight layout padding can be controlled with the `pad` keyword.
233235

234236
# %%
235-
import ultraplot as uplt
236237
import numpy as np
237238

239+
import ultraplot as uplt
240+
238241
state = np.random.RandomState(51423)
239242
fig, axs = uplt.subplots(ncols=3, nrows=3, refwidth=1.4)
240243
for ax in axs:
@@ -254,9 +257,10 @@
254257
fig.colorbar(m, label="colorbar with length <1", ticks=0.1, loc="r", length=0.7)
255258

256259
# %%
257-
import ultraplot as uplt
258260
import numpy as np
259261

262+
import ultraplot as uplt
263+
260264
state = np.random.RandomState(51423)
261265
fig, axs = uplt.subplots(
262266
ncols=2, nrows=2, order="F", refwidth=1.7, wspace=2.5, share=False
@@ -299,7 +303,7 @@
299303
# will build the required `~matplotlib.cm.ScalarMappable` on-the-fly. Lists
300304
# of :class:`~matplotlib.artist.Artists`\ s are used when you use the `colorbar`
301305
# keyword with :ref:`1D commands <ug_1dplots>` like :func:`~ultraplot.axes.PlotAxes.plot`.
302-
# * The associated :ref:`colormap normalizer <ug_norm>` can be specified with the
306+
# * The associated :ref:`colormap normalizer <ug_apply_norm>` can be specified with the
303307
# `vmin`, `vmax`, `norm`, and `norm_kw` keywords. The `~ultraplot.colors.DiscreteNorm`
304308
# levels can be specified with `values`, or UltraPlot will infer them from the
305309
# :class:`~matplotlib.artist.Artist` labels (non-numeric labels will be applied to
@@ -332,9 +336,10 @@
332336
# See :func:`~ultraplot.axes.Axes.colorbar` for details.
333337

334338
# %%
335-
import ultraplot as uplt
336339
import numpy as np
337340

341+
import ultraplot as uplt
342+
338343
fig = uplt.figure(share=False, refwidth=2)
339344

340345
# Colorbars from lines
@@ -427,9 +432,10 @@
427432
# (or use the `handle_kw` keyword). See `ultraplot.axes.Axes.legend` for details.
428433

429434
# %%
430-
import ultraplot as uplt
431435
import numpy as np
432436

437+
import ultraplot as uplt
438+
433439
uplt.rc.cycle = "538"
434440
fig, axs = uplt.subplots(ncols=2, span=False, share="labels", refwidth=2.3)
435441
labels = ["a", "bb", "ccc", "dddd", "eeeee"]

docs/why.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ like :func:`~ultraplot.axes.PlotAxes.pcolor` and :func:`~ultraplot.axes.PlotAxes
501501
* The :class:`~ultraplot.colors.DivergingNorm` normalizer is perfect for data with a
502502
:ref:`natural midpoint <ug_apply_norm>` and offers both "fair" and "unfair" scaling.
503503
The :class:`~ultraplot.colors.SegmentedNorm` normalizer can generate
504-
uneven color gradations useful for :ref:`unusual data distributions <ug_norm>`.
504+
uneven color gradations useful for :ref:`unusual data distributions <ug_apply_norm>`.
505505
* The :func:`~ultraplot.axes.PlotAxes.heatmap` command invokes
506506
:func:`~ultraplot.axes.PlotAxes.pcolormesh` then applies an `equal axes apect ratio
507507
<https://matplotlib.org/stable/gallery/subplots_axes_and_figures/axis_equal_demo.html>`__,

0 commit comments

Comments
 (0)