From 0c4bc1f8d3efeca83cf5fc727295b65a1b529b66 Mon Sep 17 00:00:00 2001 From: cvanelteren Date: Sun, 5 Jan 2025 18:28:12 +0100 Subject: [PATCH] replaced pplt -> uplt --- WHATSNEW.rst | 12 +- docs/1dplots.py | 78 ++++++------- docs/2dplots.py | 96 +++++++-------- docs/api.rst | 2 +- docs/basics.py | 72 ++++++------ docs/cartesian.py | 116 +++++++++---------- docs/colorbars_legends.py | 36 +++--- docs/colormaps.py | 74 ++++++------ docs/colors.py | 28 ++--- docs/configuration.rst | 32 ++--- docs/cycles.py | 26 ++--- docs/faq.rst | 2 +- docs/fonts.py | 12 +- docs/insets_panels.py | 14 +-- docs/projections.py | 80 ++++++------- docs/stats.py | 22 ++-- docs/subplots.py | 52 ++++----- docs/usage.rst | 6 +- docs/why.rst | 14 +-- ultraplot/axes/geo.py | 8 +- ultraplot/colors.py | 10 +- ultraplot/config.py | 22 ++-- ultraplot/constructor.py | 6 +- ultraplot/figure.py | 20 ++-- ultraplot/gridspec.py | 4 +- ultraplot/internals/docstring.py | 4 +- ultraplot/scale.py | 8 +- ultraplot/tests/test_1dplots.py | 50 ++++---- ultraplot/tests/test_2dplots.py | 70 +++++------ ultraplot/tests/test_axes.py | 28 ++--- ultraplot/tests/test_colorbar.py | 42 +++---- ultraplot/tests/test_docs.py | 2 +- ultraplot/tests/test_format.py | 64 +++++----- ultraplot/tests/test_geographic.py | 4 +- ultraplot/tests/test_inset.py | 6 +- ultraplot/tests/test_integration.py | 22 ++-- ultraplot/tests/test_legend.py | 30 ++--- ultraplot/tests/test_projections.py | 30 ++--- ultraplot/tests/test_statistical_plotting.py | 12 +- ultraplot/tests/test_subplots.py | 36 +++--- ultraplot/ticker.py | 2 +- ultraplot/utils.py | 6 +- 42 files changed, 630 insertions(+), 630 deletions(-) diff --git a/WHATSNEW.rst b/WHATSNEW.rst index e112caac9..427f5dcac 100644 --- a/WHATSNEW.rst +++ b/WHATSNEW.rst @@ -364,7 +364,7 @@ Documentation ------------- * Populate docs with examples of passing ``format`` arguments to figure and axes - instantiation commands (e.g. ``pplt.figure``, ``fig.subplot``) (:commit:`803a889f`). + instantiation commands (e.g. ``uplt.figure``, ``fig.subplot``) (:commit:`803a889f`). * Improve website colormap and cycle table rendering time by rasterizing colorbar data and add `rasterize` as optional keyword arg (:commit:`1a875fc2`). @@ -536,7 +536,7 @@ Features -------- * Permit passing ``format`` keywords when instantiating figures and axes - (:commit:`ae98378d`). For example: ``pplt.figure(suptitle='Super title')`` + (:commit:`ae98378d`). For example: ``uplt.figure(suptitle='Super title')`` or ``fig.add_subplot(111, xcolor='gray', xticks=10)`` . * Add back `color` as a valid `ultraplot.axes.CartesianAxes.format` keyword arg for consistency with `xcolor` and `ycolor` (:commit:`ecb6fa3f`). @@ -908,7 +908,7 @@ Features * Dynamically add classes that are "registered" by contructor functions to the top-level namespace (:commit:`4382a1b1`). This is consistent with behavior of importing custom-ultraplot tickers, norms, etc. to top-level namespace. - Now e.g. ``pplt.MultipleLocator`` or ``pplt.LogNorm`` are allowed. + Now e.g. ``uplt.MultipleLocator`` or ``uplt.LogNorm`` are allowed. * Allow creating subplots with `~ultraplot.ui.figure` and either (1) subsequently calling `~ultraplot.figure.Fiugure.subplots` or (2) passing integers or subplot specs generated by `~ultraplot.gridspec.GridSpec` to `~ultraplot.figure.Figure.add_subplot` @@ -951,7 +951,7 @@ Features geometry by looking up subplotspec indices (:commit:`51967ce3`). Previously 2d indexing of ``SubplotGrid`` with complex geometry would just return a wrong result. * Issue warning message when users try ``fig.subplots_adjust()`` or - ``pplt.figure(subplotpars=SubplotParams)`` and auto-disable and warn when + ``uplt.figure(subplotpars=SubplotParams)`` and auto-disable and warn when matplotlib "tight layout" rc settings are toggled (:commit:`51967ce3`). * Add nicer string representations of figures, gridspecs, subplotspecs, and axes clearly showing the geometry and layout (:commit:`51967ce3`, :commit:`6382cf91`). @@ -1013,7 +1013,7 @@ Features * Make `~ultraplot.config.rc_ultraplot` and `~ultraplot.config.rc_matplotlib` containers of ultraplot/matplotlib settings part of the public API (:commit:`a50d5264`). * Allow conversion of numeric inputs with `~ultraplot.utils.units` using e.g. - ``pplt.units(num, 'in', 'cm')`` (:commit:`88f3dc88`). + ``uplt.units(num, 'in', 'cm')`` (:commit:`88f3dc88`). * Add more intuitive :rcraw:`grid.labelpad` and :rcraw:`tick.labelpad` as aliases for :rcraw:`grid.pad` and :rcraw:`tick.pad` (:commit:`a50d5264`). * Add `~ultraplot.axes.PlotAxes.line` and `~ultraplot.axes.PlotAxes.linex` command @@ -1484,7 +1484,7 @@ Internals Documentation ------------- -* Finally use ``pplt`` as the recommended abbreviation: ``import ultraplot as pplt``. +* Finally use ``uplt`` as the recommended abbreviation: ``import ultraplot as uplt``. * Major clean up of "Why ultraplot?" page and user guide pages. * Fix incomplete ``cmap.from_file`` docstrings (:commit:`54f1bc7c`). * Rename "Changelog" to "What's New?" and list all contributors in "About the Authors". diff --git a/docs/1dplots.py b/docs/1dplots.py index baa1d06e9..c64b2f434 100644 --- a/docs/1dplots.py +++ b/docs/1dplots.py @@ -63,16 +63,16 @@ # the :rcraw:`cmap.inbounds` setting and the :ref:`user guide `). # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np N = 5 state = np.random.RandomState(51423) -with pplt.rc.context({"axes.prop_cycle": pplt.Cycle("Grays", N=N, left=0.3)}): +with uplt.rc.context({"axes.prop_cycle": uplt.Cycle("Grays", N=N, left=0.3)}): # Sample data x = np.linspace(-5, 5, N) y = state.rand(N, 5) - fig = pplt.figure(share=False, suptitle="Standardized input demonstration") + fig = uplt.figure(share=False, suptitle="Standardized input demonstration") # Plot by passing both x and y coordinates ax = fig.subplot(121, title="Manual x coordinates") @@ -92,11 +92,11 @@ fig.format(xlabel="xlabel", ylabel="ylabel") # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data -cycle = pplt.Cycle("davos", right=0.8) +cycle = uplt.Cycle("davos", right=0.8) state = np.random.RandomState(51423) N, M = 400, 20 xmax = 20 @@ -104,14 +104,14 @@ y = 100 * (state.rand(N, M) - 0.42).cumsum(axis=0) # Plot the data -fig = pplt.figure(refwidth=2.2, share=False) +fig = uplt.figure(refwidth=2.2, share=False) axs = fig.subplots([[0, 1, 1, 0], [2, 2, 3, 3]], wratios=(2, 1, 1, 2)) axs[0].axvspan( 0, xmax, zorder=3, edgecolor="red", - facecolor=pplt.set_alpha("red", 0.2), + facecolor=uplt.set_alpha("red", 0.2), ) for i, ax in enumerate(axs): inbounds = i == 1 @@ -191,17 +191,17 @@ df.columns.name = "category" # %% -import ultraplot as pplt +import ultraplot as uplt -fig = pplt.figure(share=False, suptitle="Automatic subplot formatting") +fig = uplt.figure(share=False, suptitle="Automatic subplot formatting") # Plot DataArray -cycle = pplt.Cycle("dark blue", space="hpl", N=da.shape[1]) +cycle = uplt.Cycle("dark blue", space="hpl", N=da.shape[1]) ax = fig.subplot(121) ax.scatter(da, cycle=cycle, lw=3, colorbar="t", colorbar_kw={"locator": 20}) # Plot Dataframe -cycle = pplt.Cycle("dark green", space="hpl", N=df.shape[1]) +cycle = uplt.Cycle("dark green", space="hpl", N=df.shape[1]) ax = fig.subplot(122) ax.plot(df, cycle=cycle, lw=3, legend="t", legend_kw={"frame": False}) @@ -230,7 +230,7 @@ # `__. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -241,9 +241,9 @@ data1 += state.rand(M, N) data2 += state.rand(M, N) -with pplt.rc.context({"lines.linewidth": 3}): +with uplt.rc.context({"lines.linewidth": 3}): # Use property cycle for columns of 2D input data - fig = pplt.figure(share=False) + fig = uplt.figure(share=False) ax = fig.subplot(121, title="Single plot call") ax.plot( 2 * data1 + data2, @@ -283,12 +283,12 @@ # "positive" lines using ``negpos=True`` (see :ref:`below ` for details). # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) -gs = pplt.GridSpec(nrows=3, ncols=2) -fig = pplt.figure(refwidth=2.2, span=False, share="labels") +gs = uplt.GridSpec(nrows=3, ncols=2) +fig = uplt.figure(refwidth=2.2, span=False, share="labels") # Vertical vs. horizontal data = (state.rand(10, 5) - 0.5).cumsum(axis=0) @@ -359,7 +359,7 @@ # calls `~ultraplot.axes.Axes.scatter` internally. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np import pandas as pd @@ -370,8 +370,8 @@ data = pd.DataFrame(data, columns=pd.Index(["a", "b", "c", "d"], name="label")) # Figure -gs = pplt.GridSpec(ncols=2, nrows=2) -fig = pplt.figure(refwidth=2.2, share="labels", span=False) +gs = uplt.GridSpec(ncols=2, nrows=2) +fig = uplt.figure(refwidth=2.2, share="labels", span=False) # Vertical vs. horizontal ax = fig.subplot(gs[0], title="Dependent x-axis") @@ -423,12 +423,12 @@ # plot with a colorbar indicating the parametric coordinate. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np import pandas as pd -gs = pplt.GridSpec(ncols=2, wratios=(2, 1)) -fig = pplt.figure(figwidth="16cm", refaspect=(2, 1), share=False) +gs = uplt.GridSpec(ncols=2, wratios=(2, 1)) +fig = uplt.figure(figwidth="16cm", refaspect=(2, 1), share=False) fig.format(suptitle="Parametric plots demo") cmap = "IceFire" @@ -518,7 +518,7 @@ # `~ultraplot.axes.Axes.bar` or `~ultraplot.axes.Axes.barh` internally. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np import pandas as pd @@ -532,10 +532,10 @@ ) # Figure -pplt.rc.abc = "a." -pplt.rc.titleloc = "l" -gs = pplt.GridSpec(nrows=2, hratios=(3, 2)) -fig = pplt.figure(refaspect=2, refwidth=4.8, share=False) +uplt.rc.abc = "a." +uplt.rc.titleloc = "l" +gs = uplt.GridSpec(nrows=2, hratios=(3, 2)) +fig = uplt.figure(refaspect=2, refwidth=4.8, share=False) # Side-by-side bars ax = fig.subplot(gs[0], title="Side-by-side") @@ -554,10 +554,10 @@ stack=True, ) fig.format(grid=False, suptitle="Bar plot demo") -pplt.rc.reset() +uplt.rc.reset() # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -566,9 +566,9 @@ cycle = ("gray3", "gray5", "gray7") # Figure -pplt.rc.abc = "a." -pplt.rc.titleloc = "l" -fig = pplt.figure(refwidth=2.3, share=False) +uplt.rc.abc = "a." +uplt.rc.titleloc = "l" +fig = uplt.figure(refwidth=2.3, share=False) # Overlaid area patches ax = fig.subplot(121, title="Fill between columns") @@ -594,7 +594,7 @@ legend_kw={"center": True, "ncols": 2, "labels": ["z", "y", "qqqq"]}, ) fig.format(grid=False, xlabel="xlabel", ylabel="ylabel", suptitle="Area plot demo") -pplt.rc.reset() +uplt.rc.reset() # %% [raw] raw_mimetype="text/restructuredtext" # .. _ug_negpos: @@ -613,7 +613,7 @@ # ``negcolor=color`` and ``poscolor=color`` to the `~ultraplot.axes.PlotAxes` commands. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -621,9 +621,9 @@ data = 4 * (state.rand(40) - 0.5) # Figure -pplt.rc.abc = "a." -pplt.rc.titleloc = "l" -fig, axs = pplt.subplots(nrows=3, refaspect=2, figwidth=5) +uplt.rc.abc = "a." +uplt.rc.titleloc = "l" +fig, axs = uplt.subplots(nrows=3, refaspect=2, figwidth=5) axs.format( xmargin=0, xlabel="xlabel", @@ -650,4 +650,4 @@ ax.format(title="Area plot") # Reset title styles changed above -pplt.rc.reset() +uplt.rc.reset() diff --git a/docs/2dplots.py b/docs/2dplots.py index 822df187d..4899b9199 100644 --- a/docs/2dplots.py +++ b/docs/2dplots.py @@ -77,20 +77,20 @@ # setting and the :ref:`user guide `). # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data state = np.random.RandomState(51423) x = y = np.array([-10, -5, 0, 5, 10]) -xedges = pplt.edges(x) -yedges = pplt.edges(y) +xedges = uplt.edges(x) +yedges = uplt.edges(y) data = state.rand(y.size, x.size) # "center" coordinates lim = (np.min(xedges), np.max(xedges)) -with pplt.rc.context({"cmap": "Grays", "cmap.levels": 21}): +with uplt.rc.context({"cmap": "Grays", "cmap.levels": 21}): # Figure - fig = pplt.figure(refwidth=2.3, share=False) + fig = uplt.figure(refwidth=2.3, share=False) axs = fig.subplots(ncols=2, nrows=2) axs.format( xlabel="xlabel", @@ -110,7 +110,7 @@ axs[3].contourf(xedges, yedges, data) # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -122,7 +122,7 @@ xlim = ylim = (0, 25) # Plot the data -fig, axs = pplt.subplots( +fig, axs = uplt.subplots( [[0, 1, 1, 0], [2, 2, 3, 3]], wratios=(1.3, 1, 1, 1.3), span=False, @@ -133,7 +133,7 @@ *ylim, zorder=3, edgecolor="red", - facecolor=pplt.set_alpha("red", 0.2), + facecolor=uplt.set_alpha("red", 0.2), ) for i, ax in enumerate(axs): inbounds = i == 1 @@ -223,12 +223,12 @@ df.columns.name = "variable (units)" # %% -import ultraplot as pplt +import ultraplot as uplt -fig = pplt.figure(refwidth=2.5, share=False, suptitle="Automatic subplot formatting") +fig = uplt.figure(refwidth=2.5, share=False, suptitle="Automatic subplot formatting") # Plot DataArray -cmap = pplt.Colormap("PuBu", left=0.05) +cmap = uplt.Colormap("PuBu", left=0.05) ax = fig.subplot(121, yreverse=True) ax.contourf(da, cmap=cmap, colorbar="t", lw=0.7, ec="k") @@ -265,7 +265,7 @@ # when the data limits or colormap levels cross zero (see :ref:`below `). # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -274,27 +274,27 @@ data = np.cumsum(state.rand(N, N), axis=0) # Custom defaults of each type -pplt.rc["cmap.sequential"] = "PuBuGn" -pplt.rc["cmap.diverging"] = "PiYG" -pplt.rc["cmap.cyclic"] = "bamO" -pplt.rc["cmap.qualitative"] = "flatui" +uplt.rc["cmap.sequential"] = "PuBuGn" +uplt.rc["cmap.diverging"] = "PiYG" +uplt.rc["cmap.cyclic"] = "bamO" +uplt.rc["cmap.qualitative"] = "flatui" # Make plots. Note the default behavior is sequential=True or diverging=True # depending on whether data contains negative values (see below). -fig = pplt.figure(refwidth=2.2, span=False, suptitle="Colormap types") +fig = uplt.figure(refwidth=2.2, span=False, suptitle="Colormap types") axs = fig.subplots(ncols=2, nrows=2) axs.format(xformatter="none", yformatter="none") axs[0].pcolor(data, sequential=True, colorbar="l", extend="max") axs[1].pcolor(data - 5, diverging=True, colorbar="r", extend="both") axs[2].pcolor(data % 8, cyclic=True, colorbar="l") -axs[3].pcolor(data, levels=pplt.arange(0, 12, 2), qualitative=True, colorbar="r") +axs[3].pcolor(data, levels=uplt.arange(0, 12, 2), qualitative=True, colorbar="r") types = ("sequential", "diverging", "cyclic", "qualitative") for ax, typ in zip(axs, types): ax.format(title=typ.title() + " colormap") -pplt.rc.reset() +uplt.rc.reset() # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -303,7 +303,7 @@ data = np.cumsum(state.rand(N, N), axis=1) - 6 # Continuous "diverging" colormap -fig = pplt.figure(refwidth=2.3, spanx=False) +fig = uplt.figure(refwidth=2.3, spanx=False) ax = fig.subplot(121, title="Diverging colormap with 'cmap'", xlabel="xlabel") ax.contourf( data, @@ -317,12 +317,12 @@ ax = fig.subplot(122, title="Qualitative colormap with 'colors'") ax.contourf( data, - levels=pplt.arange(-6, 9, 3), + levels=uplt.arange(-6, 9, 3), colors=["red5", "blue5", "yellow5", "gray5", "violet5"], colorbar="b", ) -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -331,8 +331,8 @@ data = 11 ** (0.25 * np.cumsum(state.rand(N, N), axis=0)) # Create figure -gs = pplt.GridSpec(ncols=2) -fig = pplt.figure(refwidth=2.3, span=False, suptitle="Normalizer types") +gs = uplt.GridSpec(ncols=2) +fig = uplt.figure(refwidth=2.3, span=False, suptitle="Normalizer types") # Different normalizers ax = fig.subplot(gs[0], title="Default linear normalizer") @@ -372,7 +372,7 @@ # affect the interpretation of different datasets. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -380,7 +380,7 @@ data = 11 ** (2 * state.rand(20, 20).cumsum(axis=0) / 7) # Linear segmented norm -fig, axs = pplt.subplots(ncols=2, refwidth=2.4) +fig, axs = uplt.subplots(ncols=2, refwidth=2.4) fig.format(suptitle="Segmented normalizer demo") ticks = [5, 10, 20, 50, 100, 200, 500, 1000] for ax, norm in zip(axs, ("linear", "segmented")): @@ -395,7 +395,7 @@ ) ax.format(title=norm.title() + " normalizer") # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -404,9 +404,9 @@ data2 = (state.rand(20, 20) - 0.515).cumsum(axis=0).cumsum(axis=1) # Figure -fig, axs = pplt.subplots(nrows=2, ncols=2, refwidth=2.2, order="F") +fig, axs = uplt.subplots(nrows=2, ncols=2, refwidth=2.2, order="F") axs.format(suptitle="Diverging normalizer demo") -cmap = pplt.Colormap("DryWet", cut=0.1) +cmap = uplt.Colormap("DryWet", cut=0.1) # Diverging norms i = 0 @@ -416,7 +416,7 @@ ("fair", "unfair"), ): for fair in ("fair", "unfair"): - norm = pplt.Norm("diverging", fair=(fair == "fair")) + norm = uplt.Norm("diverging", fair=(fair == "fair")) ax = axs[i] m = ax.contourf(data, cmap=cmap, norm=norm) ax.colorbar(m, loc="b") @@ -463,7 +463,7 @@ # the zero level (useful for single-color `~ultraplot.axes.PlotAxes.contour` plots). # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -471,7 +471,7 @@ data = 10 + state.normal(0, 1, size=(33, 33)).cumsum(axis=0).cumsum(axis=1) # Figure -fig, axs = pplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], ref=3, refwidth=2.3) +fig, axs = uplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], ref=3, refwidth=2.3) axs.format(yformatter="none", suptitle="Discrete vs. smooth colormap levels") # Pcolor @@ -485,21 +485,21 @@ axs[2].format(title="Imshow plot\ndiscrete=False (default)", yformatter="auto") # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data state = np.random.RandomState(51423) data = (20 * (state.rand(20, 20) - 0.4).cumsum(axis=0).cumsum(axis=1)) % 360 -levels = pplt.arange(0, 360, 45) +levels = uplt.arange(0, 360, 45) # Figure -gs = pplt.GridSpec(nrows=2, ncols=4, hratios=(1.5, 1)) -fig = pplt.figure(refwidth=2.4, right=2) +gs = uplt.GridSpec(nrows=2, ncols=4, hratios=(1.5, 1)) +fig = uplt.figure(refwidth=2.4, right=2) fig.format(suptitle="DiscreteNorm end-color standardization") # Cyclic colorbar with distinct end colors -cmap = pplt.Colormap("twilight", shift=-90) +cmap = uplt.Colormap("twilight", shift=-90) ax = fig.subplot(gs[0, 1:3], title='distinct "cyclic" end colors') ax.pcolormesh( data, @@ -560,31 +560,31 @@ # setting :rcraw:`cmap.autodiverging` to ``False``. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np N = 20 state = np.random.RandomState(51423) data = N * 2 + (state.rand(N, N) - 0.45).cumsum(axis=0).cumsum(axis=1) * 10 -fig, axs = pplt.subplots( +fig, axs = uplt.subplots( nrows=2, ncols=2, refwidth=2, suptitle="Auto normalization demo" ) # Auto diverging -pplt.rc["cmap.sequential"] = "lapaz_r" -pplt.rc["cmap.diverging"] = "vik" +uplt.rc["cmap.sequential"] = "lapaz_r" +uplt.rc["cmap.diverging"] = "vik" for i, ax in enumerate(axs[:2]): ax.pcolor(data - i * N * 6, colorbar="b") ax.format(title="Diverging " + ("on" if i else "off")) # Auto range -pplt.rc["cmap.sequential"] = "lajolla" +uplt.rc["cmap.sequential"] = "lajolla" data = data[::-1, :] data[-1, 0] = 2e3 for i, ax in enumerate(axs[2:]): ax.pcolor(data, robust=bool(i), colorbar="b") ax.format(title="Robust " + ("on" if i else "off")) -pplt.rc.reset() +uplt.rc.reset() # %% [raw] raw_mimetype="text/restructuredtext" # .. _ug_labels: @@ -605,7 +605,7 @@ # command documentation for details. # %% -import ultraplot as pplt +import ultraplot as uplt import pandas as pd import numpy as np @@ -615,7 +615,7 @@ data = pd.DataFrame(data, index=pd.Index(["a", "b", "c", "d", "e", "f"])) # Figure -fig, axs = pplt.subplots( +fig, axs = uplt.subplots( [[1, 1, 2, 2], [0, 3, 3, 0]], refwidth=2.3, share="labels", @@ -663,7 +663,7 @@ # `~ultraplot.axes.CartesianAxes`. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np import pandas as pd @@ -676,7 +676,7 @@ data = pd.DataFrame(data, columns=list("abcdefghij"), index=list("abcdefghij")) # Covariance matrix plot -fig, ax = pplt.subplots(refwidth=4.5) +fig, ax = uplt.subplots(refwidth=4.5) m = ax.heatmap( data, cmap="ColdHot", diff --git a/docs/api.rst b/docs/api.rst index 7f5bf5c79..e8c2361f1 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -5,7 +5,7 @@ API reference ============= The comprehensive API reference. All of the below objects are imported -into the top-level namespace. Use ``help(pplt.object)`` to read +into the top-level namespace. Use ``help(uplt.object)`` to read the docs during a python session. Please note that ultraplot removes the associated documentation when functionality diff --git a/docs/basics.py b/docs/basics.py index 3acef9591..aee847fc7 100644 --- a/docs/basics.py +++ b/docs/basics.py @@ -77,12 +77,12 @@ # %% # Simple subplot import numpy as np -import ultraplot as pplt +import ultraplot as uplt state = np.random.RandomState(51423) data = 2 * (state.rand(100, 5) - 0.5).cumsum(axis=0) -fig, ax = pplt.subplot(suptitle="Single subplot", xlabel="x axis", ylabel="y axis") -# fig = pplt.figure(suptitle='Single subplot') # equivalent to above +fig, ax = uplt.subplot(suptitle="Single subplot", xlabel="x axis", ylabel="y axis") +# fig = uplt.figure(suptitle='Single subplot') # equivalent to above # ax = fig.subplot(xlabel='x axis', ylabel='y axis') ax.plot(data, lw=2) @@ -139,17 +139,17 @@ # subplots in the same row or column share the same axis limits, scales, ticks, # and labels. This is often convenient, but may be annoying for some users. To # keep this feature turned off, simply :ref:`change the default settings ` -# with e.g. ``pplt.rc.update('subplots', share=False, span=False)``. See the +# with e.g. ``uplt.rc.update('subplots', share=False, span=False)``. See the # :ref:`axis sharing section ` for details. # %% # Simple subplot grid import numpy as np -import ultraplot as pplt +import ultraplot as uplt state = np.random.RandomState(51423) data = 2 * (state.rand(100, 5) - 0.5).cumsum(axis=0) -fig = pplt.figure() +fig = uplt.figure() ax = fig.subplot(121) ax.plot(data, lw=2) ax = fig.subplot(122) @@ -163,7 +163,7 @@ # %% # Complex grid import numpy as np -import ultraplot as pplt +import ultraplot as uplt state = np.random.RandomState(51423) data = 2 * (state.rand(100, 5) - 0.5).cumsum(axis=0) @@ -171,7 +171,7 @@ [1, 1, 2, 2], [0, 3, 3, 0], ] -fig = pplt.figure(refwidth=1.8) +fig = uplt.figure(refwidth=1.8) axs = fig.subplots(array) axs.format( abc=True, @@ -188,7 +188,7 @@ # %% # Really complex grid import numpy as np -import ultraplot as pplt +import ultraplot as uplt state = np.random.RandomState(51423) data = 2 * (state.rand(100, 5) - 0.5).cumsum(axis=0) @@ -198,7 +198,7 @@ [3, 4, 4], [3, 5, 5], ] -fig, axs = pplt.subplots(array, figwidth=5, span=False) +fig, axs = uplt.subplots(array, figwidth=5, span=False) axs.format( suptitle="Really complex subplot grid", xlabel="xlabel", ylabel="ylabel", abc=True ) @@ -209,12 +209,12 @@ # %% # Using a GridSpec import numpy as np -import ultraplot as pplt +import ultraplot as uplt state = np.random.RandomState(51423) data = 2 * (state.rand(100, 5) - 0.5).cumsum(axis=0) -gs = pplt.GridSpec(nrows=2, ncols=2, pad=1) -fig = pplt.figure(span=False, refwidth=2) +gs = uplt.GridSpec(nrows=2, ncols=2, pad=1) +fig = uplt.figure(span=False, refwidth=2) ax = fig.subplot(gs[:, 0]) ax.plot(data, lw=2) ax = fig.subplot(gs[0, 1]) @@ -237,7 +237,7 @@ # three possible return types used by `matplotlib.pyplot.subplots`: # # * `~ultraplot.gridspec.SubplotGrid` behaves like a scalar when it is singleton. -# In other words, if you make a single subplot with ``fig, axs = pplt.subplots()``, +# In other words, if you make a single subplot with ``fig, axs = uplt.subplots()``, # then ``axs[0].method(...)`` is equivalent to ``axs.method(...)``. # * `~ultraplot.gridspec.SubplotGrid` permits list-like 1D indexing, e.g. ``axs[1]`` # to return the second subplot. The subplots in the grid are sorted by @@ -268,13 +268,13 @@ # all-at-once, the subplots in the grid are sorted by `~ultraplot.axes.Axes.number`. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) # Selected subplots in a simple grid -fig, axs = pplt.subplots(ncols=4, nrows=4, refwidth=1.2, span=True) +fig, axs = uplt.subplots(ncols=4, nrows=4, refwidth=1.2, span=True) axs.format(xlabel="xlabel", ylabel="ylabel", suptitle="Simple SubplotGrid") axs.format(grid=False, xlim=(0, 50), ylim=(-4, 4)) axs[:, 0].format(facecolor="blush", edgecolor="gray7", linewidth=1) # eauivalent @@ -286,7 +286,7 @@ ax.plot((state.rand(50, 5) - 0.5).cumsum(axis=0), cycle="Grays", lw=2) # Selected subplots in a complex grid -fig = pplt.figure(refwidth=1, refnum=5, span=False) +fig = uplt.figure(refwidth=1, refnum=5, span=False) axs = fig.subplots([[1, 1, 2], [3, 4, 2], [3, 4, 5]], hratios=[2.2, 1, 1]) axs.format(xlabel="xlabel", ylabel="ylabel", suptitle="Complex SubplotGrid") axs[0].format(ec="black", fc="gray1", lw=1.4) @@ -329,7 +329,7 @@ # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -338,8 +338,8 @@ data = N + (state.rand(N, N) - 0.55).cumsum(axis=0).cumsum(axis=1) # Example plots -cycle = pplt.Cycle("greys", left=0.2, N=5) -fig, axs = pplt.subplots(ncols=2, nrows=2, figwidth=5, share=False) +cycle = uplt.Cycle("greys", left=0.2, N=5) +fig, axs = uplt.subplots(ncols=2, nrows=2, figwidth=5, share=False) axs[0].plot(data[:, :5], linewidth=2, linestyle="--", cycle=cycle) axs[1].scatter(data[:, :5], marker="x", cycle=cycle) axs[2].pcolormesh(data, cmap="greys") @@ -427,10 +427,10 @@ # used to succinctly and efficiently customize plots. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np -fig, axs = pplt.subplots(ncols=2, nrows=2, refwidth=2, share=False) +fig, axs = uplt.subplots(ncols=2, nrows=2, refwidth=2, share=False) state = np.random.RandomState(51423) N = 60 x = np.linspace(1, 10, N) @@ -455,7 +455,7 @@ xlim=(1, 10), xticks=1, ylim=(-3, 3), - yticks=pplt.arange(-3, 3), + yticks=uplt.arange(-3, 3), yticklabels=("a", "bb", "c", "dd", "e", "ff", "g"), ytickloc="both", yticklabelloc="both", @@ -492,26 +492,26 @@ # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Update global settings in several different ways -pplt.rc.metacolor = "gray6" -pplt.rc.update({"fontname": "Source Sans Pro", "fontsize": 11}) -pplt.rc["figure.facecolor"] = "gray3" -pplt.rc.axesfacecolor = "gray4" -# pplt.rc.save() # save the current settings to ~/.ultraplotrc +uplt.rc.metacolor = "gray6" +uplt.rc.update({"fontname": "Source Sans Pro", "fontsize": 11}) +uplt.rc["figure.facecolor"] = "gray3" +uplt.rc.axesfacecolor = "gray4" +# uplt.rc.save() # save the current settings to ~/.ultraplotrc # Apply settings to figure with context() -with pplt.rc.context({"suptitle.size": 13}, toplabelcolor="gray6", metawidth=1.5): - fig = pplt.figure(figwidth=6, sharey="limits", span=False) +with uplt.rc.context({"suptitle.size": 13}, toplabelcolor="gray6", metawidth=1.5): + fig = uplt.figure(figwidth=6, sharey="limits", span=False) axs = fig.subplots(ncols=2) # Plot lines with a custom cycler N, M = 100, 7 state = np.random.RandomState(51423) values = np.arange(1, M + 1) -cycle = pplt.get_colors("grays", M - 1) + ["red"] +cycle = uplt.get_colors("grays", M - 1) + ["red"] for i, ax in enumerate(axs): data = np.cumsum(state.rand(N, M) - 0.5, axis=0) lines = ax.plot(data, linewidth=3, cycle=cycle) @@ -532,21 +532,21 @@ ) # Reset persistent modifications from head of cell -pplt.rc.reset() +uplt.rc.reset() # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np -# pplt.rc.style = 'style' # set the style everywhere +# uplt.rc.style = 'style' # set the style everywhere # Sample data state = np.random.RandomState(51423) data = state.rand(10, 5) # Set up figure -fig, axs = pplt.subplots(ncols=2, nrows=2, span=False, share=False) +fig, axs = uplt.subplots(ncols=2, nrows=2, span=False, share=False) axs.format(suptitle="Stylesheets demo") styles = ("ggplot", "seaborn", "538", "bmh") diff --git a/docs/cartesian.py b/docs/cartesian.py index 3e028561d..cc2223612 100644 --- a/docs/cartesian.py +++ b/docs/cartesian.py @@ -45,18 +45,18 @@ # specific locations in a list using `~matplotlib.ticker.FixedLocator` (just # like `~matplotlib.axes.Axes.set_xticks` and `~matplotlib.axes.Axes.set_yticks`). # If you want to work with the locator classes directly, they are available in the -# top-level namespace (e.g., ``xlocator=pplt.MultipleLocator(...)`` is allowed). +# top-level namespace (e.g., ``xlocator=uplt.MultipleLocator(...)`` is allowed). # # To generate lists of tick locations, we recommend using ultraplot's # `~ultraplot.utils.arange` function -- it’s basically an endpoint-inclusive # version of `numpy.arange`, which is usually what you'll want in this context. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) -pplt.rc.update( +uplt.rc.update( metawidth=1, fontsize=10, metacolor="dark blue", @@ -64,9 +64,9 @@ titleloc="upper center", titlecolor="dark blue", titleborder=False, - axesfacecolor=pplt.scale_luminance("powderblue", 1.15), + axesfacecolor=uplt.scale_luminance("powderblue", 1.15), ) -fig = pplt.figure(share=False, refwidth=5, refaspect=(8, 1)) +fig = uplt.figure(share=False, refwidth=5, refaspect=(8, 1)) fig.format(suptitle="Tick locators demo") # Step size for tick locations @@ -97,7 +97,7 @@ ax = fig.subplot(717, title="Degree-Minute-Second Locator (requires cartopy)") ax.format(xlim=(0, 2), xlocator="dms", xformatter="dms") -pplt.rc.reset() +uplt.rc.reset() # %% [raw] raw_mimetype="text/restructuredtext" # .. _ug_formatters: @@ -124,7 +124,7 @@ # fractions of :math:`\pi`, or ``xformatter='sci'`` to label ticks with # scientific notation. If you want to work with the formatter classes # directly, they are available in the top-level namespace -# (e.g., ``xformatter=pplt.SciFormatter(...)`` is allowed). +# (e.g., ``xformatter=uplt.SciFormatter(...)`` is allowed). # # ultraplot also changes the default tick formatter to # `~ultraplot.ticker.AutoFormatter`. This class trims trailing zeros by @@ -134,14 +134,14 @@ # zero-trimming feature, set :rcraw:`formatter.zerotrim` to ``False``. # %% -import ultraplot as pplt +import ultraplot as uplt -pplt.rc.fontsize = 11 -pplt.rc.metawidth = 1.5 -pplt.rc.gridwidth = 1 +uplt.rc.fontsize = 11 +uplt.rc.metawidth = 1.5 +uplt.rc.gridwidth = 1 # Create the figure -fig, axs = pplt.subplots(ncols=2, nrows=2, refwidth=1.5, share=False) +fig, axs = uplt.subplots(ncols=2, nrows=2, refwidth=1.5, share=False) axs.format( ytickloc="both", yticklabelloc="both", @@ -178,14 +178,14 @@ xlocator=1, ylocator=1, ) -pplt.rc.reset() +uplt.rc.reset() # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np -pplt.rc.update( +uplt.rc.update( metawidth=1.2, fontsize=10, axesfacecolor="gray0", @@ -197,7 +197,7 @@ titleloc="upper center", titleborder=False, ) -fig = pplt.figure(refwidth=5, refaspect=(8, 1), share=False) +fig = uplt.figure(refwidth=5, refaspect=(8, 1), share=False) # Scientific notation ax = fig.subplot(911, title="SciFormatter") @@ -237,7 +237,7 @@ ax = fig.subplot(919, title="StrMethodFormatter") ax.format(xlim=(0, 100), xtickminor=False, xlocator=20, xformatter="{x:.1f}") fig.format(ylocator="null", suptitle="Tick formatters demo") -pplt.rc.reset() +uplt.rc.reset() # %% [raw] raw_mimetype="text/restructuredtext" # .. _pandas: https://pandas.pydata.org @@ -261,10 +261,10 @@ # and `~ultraplot.constructor.Formatter` for details. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np -pplt.rc.update( +uplt.rc.update( metawidth=1.2, fontsize=10, ticklenratio=0.7, @@ -273,7 +273,7 @@ titleloc="upper center", titleborder=False, ) -fig, axs = pplt.subplots(nrows=5, refwidth=6, refaspect=(8, 1), share=False) +fig, axs = uplt.subplots(nrows=5, refwidth=6, refaspect=(8, 1), share=False) # Default date locator # This is enabled if you plot datetime data or set datetime limits @@ -321,7 +321,7 @@ ) axs[:4].format(xrotation=0) # no rotation for the first four examples fig.format(ylocator="null", suptitle="Datetime locators and formatters demo") -pplt.rc.reset() +uplt.rc.reset() # %% [raw] raw_mimetype="text/restructuredtext" @@ -347,16 +347,16 @@ # but with additional flexibility. # %% -import ultraplot as pplt +import ultraplot as uplt -pplt.rc.update( +uplt.rc.update( metawidth=1.2, fontsize=10, gridcolor="coral", axesedgecolor="deep orange", figurefacecolor="white", ) -fig = pplt.figure(share=False, refwidth=2, suptitle="Axis locations demo") +fig = uplt.figure(share=False, refwidth=2, suptitle="Axis locations demo") # Spine location demonstration ax = fig.subplot(121, title="Various locations") @@ -371,7 +371,7 @@ ax = fig.subplot(122, title="Zero-centered spines", titlepad="1em") ax.format(xlim=(-10, 10), ylim=(-3, 3), yticks=1) ax.format(xloc="zero", yloc="zero") -pplt.rc.reset() +uplt.rc.reset() # %% [raw] raw_mimetype="text/restructuredtext" @@ -399,7 +399,7 @@ # * While matplotlib axis scales must be instantiated with an # `~matplotlib.axis.Axis` instance (for backwards compatibility reasons), # ultraplot axis scales can be instantiated without the axis instance -# (e.g., ``pplt.LogScale()`` instead of ``pplt.LogScale(ax.xaxis)``). +# (e.g., ``uplt.LogScale()`` instead of ``uplt.LogScale(ax.xaxis)``). # * The default `subs` for the ``'symlog'`` axis scale is now ``np.arange(1, 10)``, # and the default `linthresh` is now ``1``. Also the ``'log'`` and ``'symlog'`` # axis scales now accept the keywords `base`, `linthresh`, `linscale`, and @@ -414,16 +414,16 @@ # ``'inverse'`` scale `~ultraplot.scale.InverseScale` can be useful when # working with spectral data, especially with :ref:`"dual" unit axes `. # If you want to work with the axis scale classes directly, they are available -# in the top-level namespace (e.g., ``xscale=pplt.CutoffScale(...)`` is allowed). +# in the top-level namespace (e.g., ``xscale=uplt.CutoffScale(...)`` is allowed). # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np N = 200 lw = 3 -pplt.rc.update({"meta.width": 1, "label.weight": "bold", "tick.labelweight": "bold"}) -fig = pplt.figure(refwidth=1.8, share=False) +uplt.rc.update({"meta.width": 1, "label.weight": "bold", "tick.labelweight": "bold"}) +fig = uplt.figure(refwidth=1.8, share=False) # Linear and log scales ax1 = fig.subplot(221) @@ -444,11 +444,11 @@ ax.plot(np.linspace(0, 1, N), np.linspace(0.01, 0.99, N), lw=lw) fig.format(suptitle="Axis scales demo", ytickminor=True) -pplt.rc.reset() +uplt.rc.reset() # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Create figure @@ -458,8 +458,8 @@ state = np.random.RandomState(51423) data = state.rand(len(dy) - 1, len(x) - 1) colors = ("coral", "sky blue") -cmap = pplt.Colormap("grays", right=0.8) -fig, axs = pplt.subplots(nrows=4, refaspect=(5, 1), figwidth=5.5, sharex=False) +cmap = uplt.Colormap("grays", right=0.8) +fig, axs = uplt.subplots(nrows=4, refaspect=(5, 1), figwidth=5.5, sharex=False) # Loop through various cutoff scale options titles = ("Zoom out of left", "Zoom into left", "Discrete jump", "Fast jump") @@ -492,7 +492,7 @@ ) # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Create figure @@ -500,9 +500,9 @@ state = np.random.RandomState(51423) data = state.rand(n - 1, n - 1) colors = ("coral", "sky blue") -cmap = pplt.Colormap("grays", right=0.8) -gs = pplt.GridSpec(nrows=2, ncols=2) -fig = pplt.figure(refwidth=2.3, share=False) +cmap = uplt.Colormap("grays", right=0.8) +gs = uplt.GridSpec(nrows=2, ncols=2) +fig = uplt.figure(refwidth=2.3, share=False) fig.format(grid=False, suptitle="Other axis scales demo") # Geographic scales @@ -571,7 +571,7 @@ # `__ for details). # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) @@ -583,7 +583,7 @@ # Alternate y axis data = state.rand(M) + (state.rand(N, M) - 0.48).cumsum(axis=0) altdata = 5 * (state.rand(N) - 0.45).cumsum(axis=0) -fig = pplt.figure(share=False) +fig = uplt.figure(share=False) ax = fig.subplot(121, title="Alternate y twin x") ax.line(data, color=c0, ls="--") ox = ax.alty(color=c2, label="alternate ylabel", linewidth=1) @@ -626,12 +626,12 @@ # `__ axis. # %% -import ultraplot as pplt +import ultraplot as uplt -pplt.rc.update({"grid.alpha": 0.4, "meta.width": 1, "grid.linewidth": 1}) -c1 = pplt.scale_luminance("cerulean", 0.5) -c2 = pplt.scale_luminance("red", 0.5) -fig = pplt.figure(refaspect=2.2, refwidth=3, share=False) +uplt.rc.update({"grid.alpha": 0.4, "meta.width": 1, "grid.linewidth": 1}) +c1 = uplt.scale_luminance("cerulean", 0.5) +c2 = uplt.scale_luminance("red", 0.5) +fig = uplt.figure(refaspect=2.2, refwidth=3, share=False) axs = fig.subplots( [[1, 1, 2, 2], [0, 3, 3, 0]], suptitle="Duplicate axes with simple transformations", @@ -668,15 +668,15 @@ color=c2, gridcolor=c2, ) -pplt.rc.reset() +uplt.rc.reset() # %% -import ultraplot as pplt +import ultraplot as uplt -pplt.rc.update({"grid.alpha": 0.4, "meta.width": 1, "grid.linewidth": 1}) -c1 = pplt.scale_luminance("cerulean", 0.5) -c2 = pplt.scale_luminance("red", 0.5) -fig = pplt.figure( +uplt.rc.update({"grid.alpha": 0.4, "meta.width": 1, "grid.linewidth": 1}) +c1 = uplt.scale_luminance("cerulean", 0.5) +c2 = uplt.scale_luminance("red", 0.5) +fig = uplt.figure( share=False, refaspect=0.4, refwidth=1.8, @@ -709,16 +709,16 @@ ax.dualy( "pressure", label="pressure (hPa)", locator=100, color=c1, gridcolor=c1, grid=True ) -pplt.rc.reset() +uplt.rc.reset() # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np -pplt.rc.margin = 0 -c1 = pplt.scale_luminance("cerulean", 0.5) -c2 = pplt.scale_luminance("red", 0.5) -fig, ax = pplt.subplots(refaspect=(3, 1), figwidth=6) +uplt.rc.margin = 0 +c1 = uplt.scale_luminance("cerulean", 0.5) +c2 = uplt.scale_luminance("red", 0.5) +fig, ax = uplt.subplots(refaspect=(3, 1), figwidth=6) # Sample data cutoff = 1 / 5 @@ -739,4 +739,4 @@ ax = ax.dualx( "inverse", locator="log", locator_kw={"subs": (1, 2, 5)}, label="period (days)" ) -pplt.rc.reset() +uplt.rc.reset() diff --git a/docs/colorbars_legends.py b/docs/colorbars_legends.py index 627a35500..5e8ee03ae 100644 --- a/docs/colorbars_legends.py +++ b/docs/colorbars_legends.py @@ -78,11 +78,11 @@ # complex arrangements of subplots, colorbars, and legends. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) -fig = pplt.figure(share=False, refwidth=2.3) +fig = uplt.figure(share=False, refwidth=2.3) # Colorbars ax = fig.subplot(121, title="Axes colorbars") @@ -134,11 +134,11 @@ # the same legend rather than creating "stacks". # %% -import ultraplot as pplt +import ultraplot as uplt labels = list("xyzpq") state = np.random.RandomState(51423) -fig = pplt.figure(share=0, refwidth=2.3, suptitle="On-the-fly colorbar and legend demo") +fig = uplt.figure(share=0, refwidth=2.3, suptitle="On-the-fly colorbar and legend demo") # Legends data = (state.rand(30, 10) - 0.5).cumsum(axis=0) @@ -183,12 +183,12 @@ ) # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np N = 10 state = np.random.RandomState(51423) -fig, axs = pplt.subplots( +fig, axs = uplt.subplots( nrows=2, share=False, refwidth="55mm", @@ -233,11 +233,11 @@ # and the tight layout padding can be controlled with the `pad` keyword. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) -fig, axs = pplt.subplots(ncols=3, nrows=3, refwidth=1.4) +fig, axs = uplt.subplots(ncols=3, nrows=3, refwidth=1.4) for ax in axs: m = ax.pcolormesh( state.rand(20, 20), cmap="grays", levels=np.linspace(0, 1, 11), extend="both" @@ -255,11 +255,11 @@ fig.colorbar(m, label="colorbar with length <1", ticks=0.1, loc="r", length=0.7) # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) -fig, axs = pplt.subplots( +fig, axs = uplt.subplots( ncols=2, nrows=2, order="F", refwidth=1.7, wspace=2.5, share=False ) @@ -268,7 +268,7 @@ for ax in axs[:2]: m = ax.contourf(data, cmap="grays", extend="both") hs = [] -colors = pplt.get_colors("grays", 5) +colors = uplt.get_colors("grays", 5) for abc, color in zip("ABCDEF", colors): data = state.rand(10) for ax in axs[2:]: @@ -333,16 +333,16 @@ # See `~ultraplot.axes.Axes.colorbar` for details. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np -fig = pplt.figure(share=False, refwidth=2) +fig = uplt.figure(share=False, refwidth=2) # Colorbars from lines ax = fig.subplot(121) state = np.random.RandomState(51423) data = 1 + (state.rand(12, 10) - 0.45).cumsum(axis=0) -cycle = pplt.Cycle("algae") +cycle = uplt.Cycle("algae") hs = ax.line( data, lw=4, @@ -354,7 +354,7 @@ # Colorbars from a mappable ax = fig.subplot(122) -m = ax.contourf(data.T, extend="both", cmap="algae", levels=pplt.arange(0, 3, 0.5)) +m = ax.contourf(data.T, extend="both", cmap="algae", levels=uplt.arange(0, 3, 0.5)) fig.colorbar( m, loc="r", length=1, label="interior ticks", tickloc="left" # length is relative ) @@ -428,11 +428,11 @@ # (or use the `handle_kw` keyword). See `ultraplot.axes.Axes.legend` for details. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np -pplt.rc.cycle = "538" -fig, axs = pplt.subplots(ncols=2, span=False, share="labels", refwidth=2.3) +uplt.rc.cycle = "538" +fig, axs = uplt.subplots(ncols=2, span=False, share="labels", refwidth=2.3) labels = ["a", "bb", "ccc", "dddd", "eeeee"] hs1, hs2 = [], [] diff --git a/docs/colormaps.py b/docs/colormaps.py index 38e5b25cf..759ee53c6 100644 --- a/docs/colormaps.py +++ b/docs/colormaps.py @@ -86,9 +86,9 @@ # or color cycle. See `~ultraplot.colors.ColormapDatabase` for more info. # %% -import ultraplot as pplt +import ultraplot as uplt -fig, axs = pplt.show_cmaps(rasterized=True) +fig, axs = uplt.show_cmaps(rasterized=True) # %% [raw] raw_mimetype="text/restructuredtext" @@ -134,18 +134,18 @@ # %% # Colorspace demo -import ultraplot as pplt +import ultraplot as uplt -fig, axs = pplt.show_colorspaces(refwidth=1.6, luminance=50) -fig, axs = pplt.show_colorspaces(refwidth=1.6, saturation=60) -fig, axs = pplt.show_colorspaces(refwidth=1.6, hue=0) +fig, axs = uplt.show_colorspaces(refwidth=1.6, luminance=50) +fig, axs = uplt.show_colorspaces(refwidth=1.6, saturation=60) +fig, axs = uplt.show_colorspaces(refwidth=1.6, hue=0) # %% # Compare colormaps -import ultraplot as pplt +import ultraplot as uplt for cmaps in (("magma", "rocket"), ("fire", "dusk")): - fig, axs = pplt.show_channels( + fig, axs = uplt.show_channels( *cmaps, refwidth=1.5, minhue=-180, maxsat=400, rgb=False ) @@ -198,7 +198,7 @@ # %% # Sample data -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) @@ -207,15 +207,15 @@ # %% # Colormap from a color # The trailing '_r' makes the colormap go dark-to-light instead of light-to-dark -fig = pplt.figure(refwidth=2, span=False) +fig = uplt.figure(refwidth=2, span=False) ax = fig.subplot(121, title="From single named color") -cmap1 = pplt.Colormap("prussian blue_r", l=100, name="Pacific", space="hpl") +cmap1 = uplt.Colormap("prussian blue_r", l=100, name="Pacific", space="hpl") m = ax.contourf(data, cmap=cmap1) ax.colorbar(m, loc="b", ticks="none", label=cmap1.name) # Colormap from lists ax = fig.subplot(122, title="From list of colors") -cmap2 = pplt.Colormap(("maroon", "light tan"), name="Heatwave") +cmap2 = uplt.Colormap(("maroon", "light tan"), name="Heatwave") m = ax.contourf(data, cmap=cmap2) ax.colorbar(m, loc="b", ticks="none", label=cmap2.name) fig.format( @@ -223,21 +223,21 @@ ) # Display the channels -fig, axs = pplt.show_channels(cmap1, cmap2, refwidth=1.5, rgb=False) +fig, axs = uplt.show_channels(cmap1, cmap2, refwidth=1.5, rgb=False) # %% # Sequential colormap from channel values -cmap3 = pplt.Colormap( +cmap3 = uplt.Colormap( h=("red", "red-720"), s=(80, 20), l=(20, 100), space="hpl", name="CubeHelix" ) -fig = pplt.figure(refwidth=2, span=False) +fig = uplt.figure(refwidth=2, span=False) ax = fig.subplot(121, title="Sequential from channel values") m = ax.contourf(data, cmap=cmap3) ax.colorbar(m, loc="b", ticks="none", label=cmap3.name) # Cyclic colormap from channel values ax = fig.subplot(122, title="Cyclic from channel values") -cmap4 = pplt.Colormap(h=(0, 360), c=50, l=70, space="hcl", cyclic=True, name="Spectrum") +cmap4 = uplt.Colormap(h=(0, 360), c=50, l=70, space="hcl", cyclic=True, name="Spectrum") m = ax.contourf(data, cmap=cmap4) ax.colorbar(m, loc="b", ticks="none", label=cmap4.name) fig.format( @@ -245,7 +245,7 @@ ) # Display the channels -fig, axs = pplt.show_channels(cmap3, cmap4, refwidth=1.5, rgb=False) +fig, axs = uplt.show_channels(cmap3, cmap4, refwidth=1.5, rgb=False) # %% [raw] raw_mimetype="text/restructuredtext" @@ -271,23 +271,23 @@ # `~ultraplot.constructor.Colormap`. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) data = state.rand(30, 30).cumsum(axis=1) # Generate figure -fig, axs = pplt.subplots([[0, 1, 1, 0], [2, 2, 3, 3]], refwidth=2.4, span=False) +fig, axs = uplt.subplots([[0, 1, 1, 0], [2, 2, 3, 3]], refwidth=2.4, span=False) axs.format(xlabel="xlabel", ylabel="ylabel", suptitle="Merging colormaps") # Diverging colormap example title1 = "Diverging from sequential maps" -cmap1 = pplt.Colormap("Blues4_r", "Reds3", name="Diverging", save=True) +cmap1 = uplt.Colormap("Blues4_r", "Reds3", name="Diverging", save=True) # SciVisColor examples title2 = "SciVisColor example" -cmap2 = pplt.Colormap( +cmap2 = uplt.Colormap( "Greens1_r", "Oranges1", "Blues1_r", @@ -297,7 +297,7 @@ save=True, ) title3 = "SciVisColor with equal ratios" -cmap3 = pplt.Colormap( +cmap3 = uplt.Colormap( "Greens1_r", "Oranges1", "Blues1_r", "Blues6", name="SciVisColorEven", save=True ) @@ -350,14 +350,14 @@ # `__ "power" sliders. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) data = state.rand(40, 40).cumsum(axis=0) # Generate figure -fig, axs = pplt.subplots([[0, 1, 1, 0], [2, 2, 3, 3]], refwidth=1.9, span=False) +fig, axs = uplt.subplots([[0, 1, 1, 0], [2, 2, 3, 3]], refwidth=1.9, span=False) axs.format(xlabel="y axis", ylabel="x axis", suptitle="Truncating sequential colormaps") # Cutting left and right @@ -375,14 +375,14 @@ ) # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) data = (state.rand(40, 40) - 0.5).cumsum(axis=0).cumsum(axis=1) # Create figure -fig, axs = pplt.subplots(ncols=2, nrows=2, refwidth=1.7, span=False) +fig, axs = uplt.subplots(ncols=2, nrows=2, refwidth=1.7, span=False) axs.format( xlabel="x axis", ylabel="y axis", @@ -399,11 +399,11 @@ ) for i, (ax, title, cut) in enumerate(zip(axs, titles, (None, None, 0.2, -0.1))): if i % 2 == 0: - kw = {"levels": pplt.arange(-10, 10, 2)} # negative-positive cutoff + kw = {"levels": uplt.arange(-10, 10, 2)} # negative-positive cutoff else: - kw = {"values": pplt.arange(-10, 10, 2)} # dedicated center + kw = {"values": uplt.arange(-10, 10, 2)} # dedicated center if cut is not None: - fmt = pplt.SimpleFormatter() # a proper minus sign + fmt = uplt.SimpleFormatter() # a proper minus sign title = f"{title}\ncut = {fmt(cut)}" ax.format(title=title) m = ax.contourf( @@ -417,14 +417,14 @@ ) # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) data = (state.rand(50, 50) - 0.48).cumsum(axis=0).cumsum(axis=1) % 30 # Rotating cyclic colormaps -fig, axs = pplt.subplots(ncols=3, refwidth=1.7, span=False) +fig, axs = uplt.subplots(ncols=3, refwidth=1.7, span=False) for ax, shift in zip(axs, (0, 90, 180)): m = ax.pcolormesh(data, cmap="romaO", cmap_kw={"shift": shift}, levels=12) ax.format( @@ -436,17 +436,17 @@ ax.colorbar(m, loc="b", locator="null") # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) data = state.rand(20, 20).cumsum(axis=1) # Changing the colormap opacity -fig, axs = pplt.subplots(ncols=3, refwidth=1.7, span=False) +fig, axs = uplt.subplots(ncols=3, refwidth=1.7, span=False) for ax, alpha in zip(axs, (1.0, 0.5, 0.0)): alpha = (alpha, 1.0) - cmap = pplt.Colormap("batlow_r", alpha=alpha) + cmap = uplt.Colormap("batlow_r", alpha=alpha) m = ax.imshow(data, cmap=cmap, levels=10, extend="both") ax.colorbar(m, loc="b", locator="none") ax.format( @@ -457,16 +457,16 @@ ) # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) data = state.rand(20, 20).cumsum(axis=1) # Changing the colormap gamma -fig, axs = pplt.subplots(ncols=3, refwidth=1.7, span=False) +fig, axs = uplt.subplots(ncols=3, refwidth=1.7, span=False) for ax, gamma in zip(axs, (0.7, 1.0, 1.4)): - cmap = pplt.Colormap("boreal", gamma=gamma) + cmap = uplt.Colormap("boreal", gamma=gamma) m = ax.pcolormesh(data, cmap=cmap, levels=10, extend="both") ax.colorbar(m, loc="b", locator="none") ax.format( diff --git a/docs/colors.py b/docs/colors.py index ff6506893..02ace6e2c 100644 --- a/docs/colors.py +++ b/docs/colors.py @@ -54,9 +54,9 @@ # with the `space` or `margin` keywords. # %% -import ultraplot as pplt +import ultraplot as uplt -fig, axs = pplt.show_colors() +fig, axs = uplt.show_colors() # %% [raw] raw_mimetype="text/restructuredtext" @@ -74,19 +74,19 @@ # colorspace ` specified by the `space` keyword (default is ``'hcl'``). # The ``shift`` and ``scale`` functions shift or scale the # hue, saturation, or luminance by the input value -- for example, -# ``pplt.scale_luminance('color', 1.2)`` makes ``'color'`` 20% brighter. These +# ``uplt.scale_luminance('color', 1.2)`` makes ``'color'`` 20% brighter. These # are useful for creating color gradations outside of `~ultraplot.colors.Cycle` # or if you simply spot a color you like and want to make it a bit # brighter, less vibrant, etc. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Figure state = np.random.RandomState(51423) -fig, axs = pplt.subplots(ncols=3, axwidth=2) +fig, axs = uplt.subplots(ncols=3, axwidth=2) axs.format( suptitle="Modifying colors", toplabels=("Shifted hue", "Scaled luminance", "Scaled saturation"), @@ -97,23 +97,23 @@ # Shifted hue N = 50 -fmt = pplt.SimpleFormatter() +fmt = uplt.SimpleFormatter() marker = "o" for shift in (0, -60, 60): x, y = state.rand(2, N) - color = pplt.shift_hue("grass", shift) + color = uplt.shift_hue("grass", shift) axs[0].scatter(x, y, marker=marker, c=color, legend="b", label=fmt(shift)) # Scaled luminance for scale in (0.2, 1, 2): x, y = state.rand(2, N) - color = pplt.scale_luminance("bright red", scale) + color = uplt.scale_luminance("bright red", scale) axs[1].scatter(x, y, marker=marker, c=color, legend="b", label=fmt(scale)) # Scaled saturation for scale in (0, 1, 3): x, y = state.rand(2, N) - color = pplt.scale_saturation("ocean blue", scale) + color = uplt.scale_saturation("ocean blue", scale) axs[2].scatter(x, y, marker=marker, c=color, legend="b", label=fmt(scale)) # %% [raw] raw_mimetype="text/restructuredtext" @@ -134,16 +134,16 @@ # `~ultraplot.utils.to_rgba` functions to retrieve the RGB or RGBA channel values. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Initial figure and random state state = np.random.RandomState(51423) -fig = pplt.figure(refwidth=2.2, share=False) +fig = uplt.figure(refwidth=2.2, share=False) # Drawing from colormaps name = "Deep" -idxs = pplt.arange(0, 1, 0.2) +idxs = uplt.arange(0, 1, 0.2) state.shuffle(idxs) ax = fig.subplot(121, grid=True, title=f"Drawing from colormap {name!r}") for idx in idxs: @@ -156,7 +156,7 @@ legend="l", legend_kw={"ncols": 1}, ) -ax.colorbar(pplt.Colormap(name), loc="l", locator="none") +ax.colorbar(uplt.Colormap(name), loc="l", locator="none") # Drawing from color cycles name = "Qual1" @@ -173,7 +173,7 @@ legend="r", legend_kw={"ncols": 1}, ) -ax.colorbar(pplt.Colormap(name), loc="r", locator="none") +ax.colorbar(uplt.Colormap(name), loc="r", locator="none") fig.format( abc="A.", titleloc="l", diff --git a/docs/configuration.rst b/docs/configuration.rst index 41d18a70c..6b1059e0f 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -24,19 +24,19 @@ using either dot notation or as you would any other dictionary: .. code-block:: python - import ultraplot as pplt - pplt.rc.name = value - pplt.rc['name'] = value - pplt.rc.update(name1=value1, name2=value2) - pplt.rc.update({'name1': value1, 'name2': value2}) + import ultraplot as uplt + uplt.rc.name = value + uplt.rc['name'] = value + uplt.rc.update(name1=value1, name2=value2) + uplt.rc.update({'name1': value1, 'name2': value2}) To apply settings to a particular axes or figure, pass the setting to `ultraplot.axes.Axes.format` or `ultraplot.figure.Figure.format`: .. code-block:: python - import ultraplot as pplt - fig, ax = pplt.subplots() + import ultraplot as uplt + fig, ax = uplt.subplots() ax.format(name1=value1, name2=value2) ax.format(rc_kw={'name1': value1, 'name2': value2}) @@ -45,11 +45,11 @@ to the `~ultraplot.config.Configurator.context` command: .. code-block:: python - import ultraplot as pplt - with pplt.rc.context(name1=value1, name2=value2): - fig, ax = pplt.subplots() - with pplt.rc.context({'name1': value1, 'name2': value2}): - fig, ax = pplt.subplots() + import ultraplot as uplt + with uplt.rc.context(name1=value1, name2=value2): + fig, ax = uplt.subplots() + with uplt.rc.context({'name1': value1, 'name2': value2}): + fig, ax = uplt.subplots() In all of these examples, if the setting name contains dots, @@ -58,12 +58,12 @@ you can simply omit the dots. For example, to change the .. code-block:: python - import ultraplot as pplt + import ultraplot as uplt # Apply globally - pplt.rc.titleloc = value - pplt.rc.update(titleloc=value) + uplt.rc.titleloc = value + uplt.rc.update(titleloc=value) # Apply locally - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.format(titleloc=value) .. _ug_rcmatplotlib: diff --git a/docs/cycles.py b/docs/cycles.py index 18f7951b6..5d3a63983 100644 --- a/docs/cycles.py +++ b/docs/cycles.py @@ -50,9 +50,9 @@ # simply use `~ultraplot.utils.get_colors`. # %% -import ultraplot as pplt +import ultraplot as uplt -fig, axs = pplt.show_cycles(rasterized=True) +fig, axs = uplt.show_cycles(rasterized=True) # %% [raw] raw_mimetype="text/restructuredtext" @@ -72,7 +72,7 @@ # to :rcraw:`axes.prop_cycle` (see the :ref:`configuration guide `). # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -82,8 +82,8 @@ # Figure lw = 5 -pplt.rc.cycle = "538" -fig = pplt.figure(refwidth=1.9, suptitle="Changing the color cycle") +uplt.rc.cycle = "538" +fig = uplt.figure(refwidth=1.9, suptitle="Changing the color cycle") # Modify the default color cycle ax = fig.subplot(131, title="Global color cycle") @@ -122,7 +122,7 @@ # by the `~ultraplot.constructor.Colormap` constructor function. If the result # is a `~ultraplot.colors.DiscreteColormap`, those colors are used for the resulting # `~cycler.Cycler`. If the result is a `~ultraplot.colors.ContinuousColormap`, the -# colormap is sampled at `N` discrete values -- for example, ``pplt.Cycle('Blues', 5)`` +# colormap is sampled at `N` discrete values -- for example, ``uplt.Cycle('Blues', 5)`` # selects 5 evenly-spaced values. When building color cycles on-the-fly, for example # with ``ax.plot(data, cycle='Blues')``, ultraplot automatically selects as many colors # as there are columns in the 2D array (i.e., if we are drawing 10 lines using an array @@ -136,10 +136,10 @@ # generating colorbars from :ref:`lists of artists `. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np -fig = pplt.figure(refwidth=2, share=False) +fig = uplt.figure(refwidth=2, share=False) state = np.random.RandomState(51423) data = (20 * state.rand(10, 21) - 10).cumsum(axis=0) @@ -152,7 +152,7 @@ # Cycle from registered colormaps ax = fig.subplot(122) -cycle = pplt.Cycle("blues", "reds", "oranges", 15, left=0.1) +cycle = uplt.Cycle("blues", "reds", "oranges", 15, left=0.1) lines = ax.plot(data[:, :15], cycle=cycle, lw=5) fig.colorbar(lines, loc="b", col=2, values=np.arange(0, len(lines)), locator=2) fig.legend(lines, loc="b", col=2, labels=np.arange(0, len(lines)), ncols=4) @@ -171,15 +171,15 @@ # property cycler is constructed and applied to the axes locally using the # line properties `lw` and `dashes` (the aliases `linewidth` or `linewidths` # would also work). The resulting property cycle can be applied globally -# using ``pplt.rc['axes.prop_cycle'] = cycle``. +# using ``uplt.rc['axes.prop_cycle'] = cycle``. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np import pandas as pd # Cycle that loops through 'dashes' Line2D property -cycle = pplt.Cycle(lw=3, dashes=[(1, 0.5), (1, 1.5), (3, 0.5), (3, 1.5)]) +cycle = uplt.Cycle(lw=3, dashes=[(1, 0.5), (1, 1.5), (3, 0.5), (3, 1.5)]) # Sample data state = np.random.RandomState(51423) @@ -187,7 +187,7 @@ data = pd.DataFrame(data, columns=pd.Index(["a", "b", "c", "d"], name="label")) # Plot data -fig, ax = pplt.subplots(refwidth=2.5, suptitle="Plot without color cycle") +fig, ax = uplt.subplots(refwidth=2.5, suptitle="Plot without color cycle") obj = ax.plot( data, cycle=cycle, legend="ll", legend_kw={"ncols": 2, "handlelength": 2.5} ) diff --git a/docs/faq.rst b/docs/faq.rst index 56f79f303..e5f5aa773 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -7,7 +7,7 @@ What makes this project different? There is already a great matplotlib wrapper called `seaborn `__. Also, `pandas -`__ +`__ and `xarray `__ both offer convenient matplotlib plotting commands. How does ultraplot compare against these tools? diff --git a/docs/fonts.py b/docs/fonts.py index 89618ecfb..40575dcb4 100644 --- a/docs/fonts.py +++ b/docs/fonts.py @@ -70,14 +70,14 @@ # Gyre and sans-serif fonts packaged with ultraplot are shown below. # %% -import ultraplot as pplt +import ultraplot as uplt -fig, axs = pplt.show_fonts(family="sans-serif") +fig, axs = uplt.show_fonts(family="sans-serif") # %% -import ultraplot as pplt +import ultraplot as uplt -fig, axs = pplt.show_fonts(family="tex-gyre") +fig, axs = uplt.show_fonts(family="tex-gyre") # %% [raw] raw_mimetype="text/restructuredtext" # .. _ug_fonts_math: @@ -120,9 +120,9 @@ # in the text string will also use this font family. # %% -import ultraplot as pplt +import ultraplot as uplt -fig, axs = pplt.show_fonts(family="sans-serif", math=True) +fig, axs = uplt.show_fonts(family="sans-serif", math=True) # %% [raw] raw_mimetype="text/restructuredtext" # .. _ug_fonts_user: diff --git a/docs/insets_panels.py b/docs/insets_panels.py index b9e997e10..cb3a00179 100644 --- a/docs/insets_panels.py +++ b/docs/insets_panels.py @@ -62,12 +62,12 @@ # most complex arrangements of subplots and panels. # %% -import ultraplot as pplt +import ultraplot as uplt # Demonstrate that complex arrangements preserve # spacing, aspect ratios, and axis sharing -gs = pplt.GridSpec(nrows=2, ncols=2) -fig = pplt.figure(refwidth=1.5, share=False) +gs = uplt.GridSpec(nrows=2, ncols=2) +fig = uplt.figure(refwidth=1.5, share=False) for ss, side in zip(gs, "tlbr"): ax = fig.add_subplot(ss) px = ax.panel_axes(side, width="3em") @@ -88,7 +88,7 @@ ) # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) @@ -98,7 +98,7 @@ # Stacked panels with outer colorbars for cbarloc, ploc in ("rb", "br"): # Create figure - fig, axs = pplt.subplots( + fig, axs = uplt.subplots( nrows=1, ncols=2, refwidth=1.8, panelpad=0.8, share=False, includepanels=True ) axs.format( @@ -166,7 +166,7 @@ # axes. To modify the zoom line properties, you can pass a dictionary to `zoom_kw`. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -177,7 +177,7 @@ data = np.flip(data, (0, 1)) # Plot data in the main axes -fig, ax = pplt.subplots(refwidth=3) +fig, ax = uplt.subplots(refwidth=3) m = ax.pcolormesh(data, cmap="Grays", levels=N) ax.colorbar(m, loc="b", label="label") ax.format(xlabel="xlabel", ylabel="ylabel", suptitle='"Zooming in" with an inset axes') diff --git a/docs/projections.py b/docs/projections.py index 039cd6923..a7276e2d9 100644 --- a/docs/projections.py +++ b/docs/projections.py @@ -55,14 +55,14 @@ # For details, see `ultraplot.axes.PolarAxes.format`. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np N = 200 state = np.random.RandomState(51423) x = np.linspace(0, 2 * np.pi, N)[:, None] + np.arange(5) * 2 * np.pi / 5 y = 100 * (state.rand(N, 5) - 0.3).cumsum(axis=0) / N -fig, axs = pplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], proj="polar") +fig, axs = uplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], proj="polar") axs.format( suptitle="Polar axes demo", linewidth=1, @@ -79,7 +79,7 @@ title="Normal plot", thetaformatter="tau", rlabelpos=225, - rlines=pplt.arange(5, 30, 5), + rlines=uplt.arange(5, 30, 5), edgecolor="red8", tickpad="1em", ) @@ -92,7 +92,7 @@ thetalim=(0, 270), theta0="N", rlim=(0, 22), - rlines=pplt.arange(5, 30, 5), + rlines=uplt.arange(5, 30, 5), ) # Annular plot @@ -132,12 +132,12 @@ # %% # Use an on-the-fly projection -import ultraplot as pplt +import ultraplot as uplt -fig = pplt.figure(refwidth=3) +fig = uplt.figure(refwidth=3) axs = fig.subplots(nrows=2, proj="robin", proj_kw={"lon0": 150}) -# proj = pplt.Proj('robin', lon0=180) -# axs = pplt.subplots(nrows=2, proj=proj) # equivalent to above +# proj = uplt.Proj('robin', lon0=180) +# axs = uplt.subplots(nrows=2, proj=proj) # equivalent to above axs.format( suptitle="Figure with single projection", land=True, @@ -166,7 +166,7 @@ # cartopy. If you need to use the underlying `~cartopy.crs.Projection` instance, it # is available via the `~ultraplot.axes.GeoAxes.projection` attribute. If you want # to work with the projection classes directly, they are available in the -# top-level namespace (e.g., ``proj=pplt.PlateCarre()`` is allowed). +# top-level namespace (e.g., ``proj=uplt.PlateCarre()`` is allowed). # # * Basemap is an alternative backend. To use basemap, set :rcraw:`geo.backend` to # ``'basemap'`` or pass ``backend='basemap'`` to the axes-creation command. When @@ -225,12 +225,12 @@ # in a future release and fully remove basemap support by version 1.0.0. # %% -import ultraplot as pplt +import ultraplot as uplt -fig = pplt.figure() +fig = uplt.figure() # Add projections -gs = pplt.GridSpec(ncols=2, nrows=3, hratios=(1, 1, 1.4)) +gs = uplt.GridSpec(ncols=2, nrows=3, hratios=(1, 1, 1.4)) for i, proj in enumerate(("cyl", "hammer", "npstere")): ax1 = fig.subplot(gs[i, 0], proj=proj) # default cartopy backend ax2 = fig.subplot(gs[i, 1], proj=proj, backend="basemap") # basemap backend @@ -248,7 +248,7 @@ axs[:2].format(lonlabels="b", latlabels="r") # or lonlabels=True, lonlabels='bottom', axs[2:4].format(lonlabels=False, latlabels="both") axs[4:].format(lonlabels="all", lonlines=30) -pplt.rc.reset() +uplt.rc.reset() # %% [raw] raw_mimetype="text/restructuredtext" @@ -276,25 +276,25 @@ # the `zorder `__ # property for that feature. For example, to draw land patches on top of all plotted # content as a "land mask" you can use ``ax.format(land=True, landzorder=4)`` or set -# ``pplt.rc['land.zorder'] = 4`` (see the :ref:`next section ` +# ``uplt.rc['land.zorder'] = 4`` (see the :ref:`next section ` # for details). # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Fake data with unusual longitude seam location and without coverage over poles offset = -40 -lon = pplt.arange(offset, 360 + offset - 1, 60) -lat = pplt.arange(-60, 60 + 1, 30) +lon = uplt.arange(offset, 360 + offset - 1, 60) +lat = uplt.arange(-60, 60 + 1, 30) state = np.random.RandomState(51423) data = state.rand(len(lat), len(lon)) # Plot data both without and with globe=True for globe in (False, True): string = "with" if globe else "without" - gs = pplt.GridSpec(nrows=2, ncols=2) - fig = pplt.figure(refwidth=2.5) + gs = uplt.GridSpec(nrows=2, ncols=2) + fig = uplt.figure(refwidth=2.5) for i, ss in enumerate(gs): cmap = ("sunset", "sunrise")[i % 2] backend = ("cartopy", "basemap")[i % 2] @@ -349,10 +349,10 @@ # For details, see the `ultraplot.axes.GeoAxes.format` documentation. # %% -import ultraplot as pplt +import ultraplot as uplt -gs = pplt.GridSpec(ncols=3, nrows=2, wratios=(1, 1, 1.2), hratios=(1, 1.2)) -fig = pplt.figure(refwidth=4) +gs = uplt.GridSpec(ncols=3, nrows=2, wratios=(1, 1, 1.2), hratios=(1, 1.2)) +fig = uplt.figure(refwidth=4) # Styling projections in different ways ax = fig.subplot(gs[0, :2], proj="eqearth") @@ -442,12 +442,12 @@ # projections with `format` after they have already been created. # %% -import ultraplot as pplt +import ultraplot as uplt # Plate Carrée map projection -pplt.rc.reso = "med" # use higher res for zoomed in geographic features -basemap = pplt.Proj("cyl", lonlim=(-20, 180), latlim=(-10, 50), backend="basemap") -fig, axs = pplt.subplots(nrows=2, refwidth=5, proj=("cyl", basemap)) +uplt.rc.reso = "med" # use higher res for zoomed in geographic features +basemap = uplt.Proj("cyl", lonlim=(-20, 180), latlim=(-10, 50), backend="basemap") +fig, axs = uplt.subplots(nrows=2, refwidth=5, proj=("cyl", basemap)) axs.format( land=True, labels=True, @@ -461,35 +461,35 @@ axs[1].format(title="Basemap example") # %% -import ultraplot as pplt +import ultraplot as uplt # Pole-centered map projections -basemap = pplt.Proj("npaeqd", boundinglat=60, backend="basemap") -fig, axs = pplt.subplots(ncols=2, refwidth=2.7, proj=("splaea", basemap)) +basemap = uplt.Proj("npaeqd", boundinglat=60, backend="basemap") +fig, axs = uplt.subplots(ncols=2, refwidth=2.7, proj=("splaea", basemap)) fig.format(suptitle="Zooming into polar projections") axs.format(land=True, latmax=80) # no gridlines poleward of 80 degrees axs[0].format(boundinglat=-60, title="Cartopy example") axs[1].format(title="Basemap example") # %% -import ultraplot as pplt +import ultraplot as uplt # Zooming in on continents -fig = pplt.figure(refwidth=3) +fig = uplt.figure(refwidth=3) ax = fig.subplot(121, proj="lcc", proj_kw={"lon0": 0}) ax.format(lonlim=(-20, 50), latlim=(30, 70), title="Cartopy example") -proj = pplt.Proj("lcc", lon0=-100, lat0=45, width=8e6, height=8e6, backend="basemap") +proj = uplt.Proj("lcc", lon0=-100, lat0=45, width=8e6, height=8e6, backend="basemap") ax = fig.subplot(122, proj=proj) ax.format(lonlines=20, title="Basemap example") fig.format(suptitle="Zooming into specific regions", land=True) # %% -import ultraplot as pplt +import ultraplot as uplt # Zooming in with cartopy degree-minute-second labels -pplt.rc.reso = "hi" -fig = pplt.figure(refwidth=2.5) +uplt.rc.reso = "hi" +fig = uplt.figure(refwidth=2.5) ax = fig.subplot(121, proj="cyl") ax.format(lonlim=(-7.5, 2), latlim=(49.5, 59)) ax = fig.subplot(122, proj="cyl") @@ -501,7 +501,7 @@ borderscolor="white", suptitle="Cartopy degree-minute-second labels", ) -pplt.rc.reset() +uplt.rc.reset() # %% [raw] raw_mimetype="text/restructuredtext" # .. _proj_included: @@ -523,7 +523,7 @@ # and `~cartopy.crs.SouthPolarStereo` projections. # %% -import ultraplot as pplt +import ultraplot as uplt # Table of cartopy projections projs = [ @@ -558,13 +558,13 @@ "eck5", "eck6", ] -fig, axs = pplt.subplots(ncols=3, nrows=10, figwidth=7, proj=projs) +fig, axs = uplt.subplots(ncols=3, nrows=10, figwidth=7, proj=projs) axs.format(land=True, reso="lo", labels=False, suptitle="Table of cartopy projections") for proj, ax in zip(projs, axs): ax.format(title=proj, titleweight="bold", labels=False) # %% -import ultraplot as pplt +import ultraplot as uplt # Table of basemap projections projs = [ @@ -593,7 +593,7 @@ "npaeqd", "nplaea", ] -fig, axs = pplt.subplots(ncols=3, nrows=8, figwidth=7, proj=projs, backend="basemap") +fig, axs = uplt.subplots(ncols=3, nrows=8, figwidth=7, proj=projs, backend="basemap") axs.format(land=True, labels=False, suptitle="Table of basemap projections") for proj, ax in zip(projs, axs): ax.format(title=proj, titleweight="bold", labels=False) diff --git a/docs/stats.py b/docs/stats.py index 57fc30fa8..245392c63 100644 --- a/docs/stats.py +++ b/docs/stats.py @@ -79,7 +79,7 @@ shadedata = np.percentile(data, (25, 75), axis=0) # dark shading # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Loop through "vertical" and "horizontal" versions @@ -87,7 +87,7 @@ harray = [[1, 1], [2, 3], [2, 3]] for orientation, array in zip(("vertical", "horizontal"), (varray, harray)): # Figure - fig = pplt.figure(refwidth=4, refaspect=1.5, share=False) + fig = uplt.figure(refwidth=4, refaspect=1.5, share=False) axs = fig.subplots(array, hratios=(2, 1, 1)) axs.format(abc="A.", suptitle=f"Indicating {orientation} error bounds") @@ -164,7 +164,7 @@ # with the same keywords used for :ref:`on-the-fly error bars `. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np import pandas as pd @@ -177,7 +177,7 @@ data2 = pd.DataFrame(data2, columns=pd.Index(list("abcdefg"), name="label")) # Figure -fig, axs = pplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], span=False) +fig, axs = uplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], span=False) axs.format(abc="A.", titleloc="l", grid=False, suptitle="Boxes and violins demo") # Box plots @@ -221,7 +221,7 @@ # will use the same algorithm for kernel density estimation as the `kde` commands. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -230,11 +230,11 @@ x = state.normal(size=(M, N)) + state.rand(M)[:, None] * np.arange(N) + 2 * np.arange(N) # Sample overlayed histograms -fig, ax = pplt.subplots(refwidth=4, refaspect=(3, 2)) +fig, ax = uplt.subplots(refwidth=4, refaspect=(3, 2)) ax.format(suptitle="Overlaid histograms", xlabel="distribution", ylabel="count") res = ax.hist( x, - pplt.arange(-3, 8, 0.2), + uplt.arange(-3, 8, 0.2), filled=True, alpha=0.7, edgecolor="k", @@ -244,7 +244,7 @@ ) # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Sample data @@ -252,10 +252,10 @@ state = np.random.RandomState(51423) x = state.normal(size=(N,)) y = state.normal(size=(N,)) -bins = pplt.arange(-3, 3, 0.25) +bins = uplt.arange(-3, 3, 0.25) # Histogram with marginal distributions -fig, axs = pplt.subplots(ncols=2, refwidth=2.3) +fig, axs = uplt.subplots(ncols=2, refwidth=2.3) axs.format( abc="A.", abcloc="l", @@ -277,7 +277,7 @@ colorbar="b", colorbar_kw={"label": "count"}, ) - color = pplt.scale_luminance(color, 1.5) # histogram colors + color = uplt.scale_luminance(color, 1.5) # histogram colors px = ax.panel(which, space=0) px.histh(y, bins, color=color, fill=True, ec="k") px.format(grid=False, xlocator=[], xreverse=(which == "l")) diff --git a/docs/subplots.py b/docs/subplots.py index 245a501ba..ff2b6e180 100644 --- a/docs/subplots.py +++ b/docs/subplots.py @@ -77,9 +77,9 @@ # passing ``border=True`` or ``bbox=True`` to `ultraplot.axes.Axes.text`. # %% -import ultraplot as pplt +import ultraplot as uplt -fig = pplt.figure(space=0, refwidth="10em") +fig = uplt.figure(space=0, refwidth="10em") axs = fig.subplots(nrows=3, ncols=3) axs.format( abc="A.", @@ -96,9 +96,9 @@ # axs[:-3].format(abcborder=True) # this is already the default # %% -import ultraplot as pplt +import ultraplot as uplt -fig = pplt.figure(space=0, refwidth=0.7) +fig = uplt.figure(space=0, refwidth=0.7) axs = fig.subplots(nrows=8, ncols=8) axs.format( abc=True, @@ -180,32 +180,32 @@ # depending on the number of subplots in the figure. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np # Grid of images (note the square pixels) state = np.random.RandomState(51423) colors = np.tile(state.rand(8, 12, 1), (1, 1, 3)) -fig, axs = pplt.subplots(ncols=3, nrows=2, refwidth=1.7) +fig, axs = uplt.subplots(ncols=3, nrows=2, refwidth=1.7) fig.format(suptitle="Auto figure dimensions for grid of images") for ax in axs: ax.imshow(colors) # Grid of cartopy projections -fig, axs = pplt.subplots(ncols=2, nrows=3, proj="robin") +fig, axs = uplt.subplots(ncols=2, nrows=3, proj="robin") axs.format(land=True, landcolor="k") fig.format(suptitle="Auto figure dimensions for grid of cartopy projections") # %% -import ultraplot as pplt +import ultraplot as uplt -pplt.rc.update(grid=False, titleloc="uc", titleweight="bold", titlecolor="red9") +uplt.rc.update(grid=False, titleloc="uc", titleweight="bold", titlecolor="red9") # Change the reference subplot width suptitle = "Effect of subplot width on figure size" for refwidth in ("3cm", "5cm"): - fig, axs = pplt.subplots( + fig, axs = uplt.subplots( ncols=2, refwidth=refwidth, ) @@ -214,19 +214,19 @@ # Change the reference subplot aspect ratio suptitle = "Effect of subplot aspect ratio on figure size" for refaspect in (1, 2): - fig, axs = pplt.subplots(ncols=2, refwidth=1.6, refaspect=refaspect) + fig, axs = uplt.subplots(ncols=2, refwidth=1.6, refaspect=refaspect) axs[0].format(title=f"refaspect = {refaspect}", suptitle=suptitle) # Change the reference subplot suptitle = "Effect of reference subplot on figure size" for ref in (1, 2): # with different width ratios - fig, axs = pplt.subplots(ncols=3, wratios=(3, 2, 2), ref=ref, refwidth=1.1) + fig, axs = uplt.subplots(ncols=3, wratios=(3, 2, 2), ref=ref, refwidth=1.1) axs[ref - 1].format(title="reference", suptitle=suptitle) for ref in (1, 2): # with complex subplot grid - fig, axs = pplt.subplots([[1, 2], [1, 3]], refnum=ref, refwidth=1.8) + fig, axs = uplt.subplots([[1, 2], [1, 3]], refnum=ref, refwidth=1.8) axs[ref - 1].format(title="reference", suptitle=suptitle) -pplt.rc.reset() +uplt.rc.reset() # %% [raw] raw_mimetype="text/restructuredtext" # .. _ug_tight: @@ -281,11 +281,11 @@ # (note the spacing between the first and second row in the below example). # %% -import ultraplot as pplt +import ultraplot as uplt # Stress test of the tight layout algorithm # This time override the algorithm between selected subplot rows/columns -fig, axs = pplt.subplots( +fig, axs = uplt.subplots( ncols=4, nrows=3, refwidth=1.1, @@ -316,7 +316,7 @@ # %% -import ultraplot as pplt +import ultraplot as uplt # Stress test of the tight layout algorithm # Add large labels along the edge of one subplot @@ -325,7 +325,7 @@ for (name1, equal), (name2, group) in zip(equals, groups): suffix = " (default)" if group and not equal else "" suptitle = f'Tight layout with "{name1}" and "{name2}" row-column spacing{suffix}' - fig, axs = pplt.subplots( + fig, axs = uplt.subplots( nrows=3, ncols=3, refwidth=1.1, @@ -389,13 +389,13 @@ # settings on the appearance of several subplot grids. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np N = 50 M = 40 state = np.random.RandomState(51423) -cycle = pplt.Cycle("grays_r", M, left=0.1, right=0.8) +cycle = uplt.Cycle("grays_r", M, left=0.1, right=0.8) datas = [] for scale in (1, 3, 7, 0.2): data = scale * (state.rand(N, M) - 0.5).cumsum(axis=0)[N // 2 :, :] @@ -406,7 +406,7 @@ spans = (False, False, True, True) shares = (False, "labels", "limits", True) for i, (span, share) in enumerate(zip(spans, shares)): - fig = pplt.figure(refaspect=1, refwidth=1.06, spanx=span, sharey=share) + fig = uplt.figure(refaspect=1, refwidth=1.06, spanx=span, sharey=share) axs = fig.subplots(ncols=4) for ax, data in zip(axs, datas): on = ("off", "on")[int(span)] @@ -419,7 +419,7 @@ ) # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np state = np.random.RandomState(51423) @@ -430,7 +430,7 @@ shares = (False, "all") titles = ("Minimum sharing", "Maximum sharing") for span, share, title in zip(spans, shares, titles): - fig = pplt.figure(refwidth=1, span=span, share=share) + fig = uplt.figure(refwidth=1, span=span, share=share) axs = fig.subplots(nrows=4, ncols=4) for ax in axs: data = (state.rand(100, 20) - 0.4).cumsum(axis=0) @@ -480,11 +480,11 @@ # and `points `__. # %% -import ultraplot as pplt +import ultraplot as uplt import numpy as np -with pplt.rc.context(fontsize="12px"): # depends on rc['figure.dpi'] - fig, axs = pplt.subplots( +with uplt.rc.context(fontsize="12px"): # depends on rc['figure.dpi'] + fig, axs = uplt.subplots( ncols=3, figwidth="15cm", figheight="3in", diff --git a/docs/usage.rst b/docs/usage.rst index 880d51e44..8713b8e3c 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -52,7 +52,7 @@ We recommend importing ultraplot as follows: .. code-block:: python - import ultraplot as pplt + import ultraplot as uplt This differentiates ultraplot from the usual ``plt`` abbreviation reserved for the `~matplotlib.pyplot` module. @@ -68,14 +68,14 @@ all of its subplots at once: .. code-block:: python - fig, axs = pplt.subplots(...) + fig, axs = uplt.subplots(...) or create an empty figure then fill it with subplots: .. code-block:: python - fig = pplt.figure(...) + fig = uplt.figure(...) axs = fig.add_subplots(...) # add several subplots ax = fig.add_subplot(...) # add a single subplot # axs = fig.subplots(...) # shorthand diff --git a/docs/why.rst b/docs/why.rst index 0c986e2e5..3a3c8cf71 100644 --- a/docs/why.rst +++ b/docs/why.rst @@ -96,8 +96,8 @@ highly customized figures. As an example, it is trivial to see that... .. code-block:: python - import ultraplot as pplt - fig, axs = pplt.subplots(ncols=2) + import ultraplot as uplt + fig, axs = uplt.subplots(ncols=2) axs.format(color='gray', linewidth=1) axs.format(xlim=(0, 100), xticks=10, xtickminor=True, xlabel='foo', ylabel='bar') @@ -172,7 +172,7 @@ and `~ultraplot.constructor.Colormap` accept colormap names, individual colors, lists of colors. Passing the relevant class instance to a constructor function simply returns it, and all the registered classes are available in the top-level namespace -- so class instances can be directly created with e.g. -``pplt.MultipleLocator(...)`` or ``pplt.LogNorm(...)`` rather than +``uplt.MultipleLocator(...)`` or ``uplt.LogNorm(...)`` rather than relying on constructor functions. The below table lists the constructor functions and the keyword arguments that use them. @@ -330,7 +330,7 @@ concise figures. one subplot in arbitrary contiguous rows and columns. See the :ref:`next section ` for details. * A-b-c labels can be added to subplots simply using the :rcraw:`abc` - setting -- for example, ``pplt.rc['abc'] = 'A.'`` or ``axs.format(abc='A.')``. + setting -- for example, ``uplt.rc['abc'] = 'A.'`` or ``axs.format(abc='A.')``. This is possible because `~ultraplot.figure.Figure.add_subplot` assigns a unique `~ultraplot.axes.Axes.number` to every new subplot. * The `ultraplot.gridspec.SubplotGrid.format` command can easily format multiple subplots @@ -559,7 +559,7 @@ ultraplot can succinctly create detailed geographic plots using either cartopy o basemap as "backends". By default, cartopy is used, but basemap can be used by passing ``backend='basemap'`` to axes-creation commands or by setting :rcraw:`geo.backend` to ``'basemap'``. To create a geographic plot, simply pass the `PROJ `__ -name to an axes-creation command, e.g. ``fig, ax = pplt.subplots(proj='pcarree')`` +name to an axes-creation command, e.g. ``fig, ax = uplt.subplots(proj='pcarree')`` or ``fig.add_subplot(proj='pcarree')``. Alternatively, use the `~ultraplot.constructor.Proj` constructor function to quickly generate a `cartopy.crs.Projection` or `~mpl_toolkits.basemap.Basemap` instance. @@ -852,8 +852,8 @@ matplotlib settings (found in `~ultraplot.config.rc_matplotlib`) and added ultra settings (found in `~ultraplot.config.rc_ultraplot`). Assigned settings are always validated, and "meta" settings like ``meta.edgecolor``, ``meta.linewidth``, and ``font.smallsize`` can be used to update many settings all at once. Settings can -be changed with ``pplt.rc.key = value``, ``pplt.rc[key] = value``, -``pplt.rc.update(key=value)``, using `ultraplot.axes.Axes.format`, or using +be changed with ``uplt.rc.key = value``, ``uplt.rc[key] = value``, +``uplt.rc.update(key=value)``, using `ultraplot.axes.Axes.format`, or using `ultraplot.config.Configurator.context`. Settings that have changed during the python session can be saved to a file with `ultraplot.config.Configurator.save` (see `~ultraplot.config.Configurator.changed`), and settings can be loaded from diff --git a/ultraplot/axes/geo.py b/ultraplot/axes/geo.py index 75478d884..570222765 100644 --- a/ultraplot/axes/geo.py +++ b/ultraplot/axes/geo.py @@ -1474,8 +1474,8 @@ def _update_boundary(self, round=None): else: warnings._warn_ultraplot( f"Got round={round!r}, but you cannot change the bounds of a polar " - "basemap projection after creating it. Please pass 'round' to pplt.Proj " # noqa: E501 - "instead (e.g. using the pplt.subplots() dictionary keyword 'proj_kw')." + "basemap projection after creating it. Please pass 'round' to uplt.Proj " # noqa: E501 + "instead (e.g. using the uplt.subplots() dictionary keyword 'proj_kw')." ) def _update_extent_mode(self, extent=None, boundinglat=None): # noqa: U100 @@ -1505,8 +1505,8 @@ def _update_extent(self, lonlim=None, latlim=None, boundinglat=None): warnings._warn_ultraplot( f"Got lonlim={lonlim!r}, latlim={latlim!r}, boundinglat={boundinglat!r}" ', but you cannot "zoom into" a basemap projection after creating it. ' - "Please pass any of the following keyword arguments to pplt.Proj " - "instead (e.g. using the pplt.subplots() dictionary keyword 'proj_kw'):" + "Please pass any of the following keyword arguments to uplt.Proj " + "instead (e.g. using the uplt.subplots() dictionary keyword 'proj_kw'):" "'boundinglat', 'lonlim', 'latlim', 'llcrnrlon', 'llcrnrlat', " "'urcrnrlon', 'urcrnrlat', 'llcrnrx', 'llcrnry', 'urcrnrx', 'urcrnry', " "'width', or 'height'." diff --git a/ultraplot/colors.py b/ultraplot/colors.py index 7338db313..53c8908b4 100644 --- a/ultraplot/colors.py +++ b/ultraplot/colors.py @@ -3,7 +3,7 @@ Various colormap classes and colormap normalization classes. """ # NOTE: To avoid name conflicts between registered colormaps and colors, print -# set(pplt.colors._cmap_database) & set(pplt.colors._color_database) whenever +# set(uplt.colors._cmap_database) & set(uplt.colors._color_database) whenever # you add new colormaps. v0.8 result is {'gray', 'marine', 'ocean', 'pink'} due # to the MATLAB and GNUPlot colormaps. Want to minimize conflicts. # NOTE: We feel that LinearSegmentedColormap should always be used for smooth color @@ -2002,13 +2002,13 @@ def __init__( `segmentdata` dictionary that uses color names for the hue data, instead of channel values between ``0`` and ``360``. - >>> import ultraplot as pplt + >>> import ultraplot as uplt >>> data = { >>> 'h': [[0, 'red', 'red'], [1, 'blue', 'blue']], >>> 's': [[0, 100, 100], [1, 100, 100]], >>> 'l': [[0, 100, 100], [1, 20, 20]], >>> } - >>> cmap = pplt.PerceptualColormap(data) + >>> cmap = uplt.PerceptualColormap(data) See also -------- @@ -2686,11 +2686,11 @@ def __init__(self, levels, vmin=None, vmax=None, clip=False): `~matplotlib.axes.Axes.contourf`, resulting in the automatic application of `SegmentedNorm`. - >>> import ultraplot as pplt + >>> import ultraplot as uplt >>> import numpy as np >>> levels = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000] >>> data = 10 ** (3 * np.random.rand(10, 10)) - >>> fig, ax = pplt.subplots() + >>> fig, ax = uplt.subplots() >>> ax.contourf(data, levels=levels) """ # WARNING: Tried using descending levels by adding 1 - yq to __call__() and diff --git a/ultraplot/config.py b/ultraplot/config.py index 42520b836..b4021ae0a 100644 --- a/ultraplot/config.py +++ b/ultraplot/config.py @@ -757,7 +757,7 @@ def __init__(self, local=True, user=True, default=True, **kwargs): def __getitem__(self, key): """ Return an `rc_matplotlib` or `rc_ultraplot` setting using dictionary notation - (e.g., ``value = pplt.rc[name]``). + (e.g., ``value = uplt.rc[name]``). """ key, _ = self._validate_key(key) # might issue ultraplot removed/renamed error try: @@ -769,7 +769,7 @@ def __getitem__(self, key): def __setitem__(self, key, value): """ Modify an `rc_matplotlib` or `rc_ultraplot` setting using dictionary notation - (e.g., ``pplt.rc[name] = value``). + (e.g., ``uplt.rc[name] = value``). """ kw_ultraplot, kw_matplotlib = self._get_item_dicts(key, value) rc_ultraplot.update(kw_ultraplot) @@ -778,7 +778,7 @@ def __setitem__(self, key, value): def __getattr__(self, attr): """ Return an `rc_matplotlib` or `rc_ultraplot` setting using "dot" notation - (e.g., ``value = pplt.rc.name``). + (e.g., ``value = uplt.rc.name``). """ if attr[:1] == "_": return super().__getattribute__(attr) # raise built-in error @@ -788,7 +788,7 @@ def __getattr__(self, attr): def __setattr__(self, attr, value): """ Modify an `rc_matplotlib` or `rc_ultraplot` setting using "dot" notation - (e.g., ``pplt.rc.name = value``). + (e.g., ``uplt.rc.name = value``). """ if attr[:1] == "_": super().__setattr__(attr, value) @@ -1397,8 +1397,8 @@ def context(self, *args, mode=0, file=None, **kwargs): * ``mode=1``: Matplotlib's `rc_matplotlib` settings are only returned if they are local to the "with as" block. For example, if :rcraw:`axes.titlesize` was passed to `~Configurator.context`, - then ``pplt.rc.find('axes.titlesize', context=True)`` will return - this value, but ``pplt.rc.find('axes.titleweight', context=True)`` will + then ``uplt.rc.find('axes.titlesize', context=True)`` will return + this value, but ``uplt.rc.find('axes.titleweight', context=True)`` will return ``None``. This is used internally when instantiating axes. * ``mode=2``: Matplotlib's `rc_matplotlib` settings and ultraplot's `rc_ultraplot` settings are only returned if they are local to the @@ -1418,17 +1418,17 @@ def context(self, *args, mode=0, file=None, **kwargs): The below applies settings to axes in a specific figure using `~Configurator.context`. - >>> import ultraplot as pplt - >>> with pplt.rc.context(ticklen=5, metalinewidth=2): - >>> fig, ax = pplt.subplots() + >>> import ultraplot as uplt + >>> with uplt.rc.context(ticklen=5, metalinewidth=2): + >>> fig, ax = uplt.subplots() >>> ax.plot(data) The below applies settings to a specific axes using `~ultraplot.axes.Axes.format`, which uses `~Configurator.context` internally. - >>> import ultraplot as pplt - >>> fig, ax = pplt.subplots() + >>> import ultraplot as uplt + >>> fig, ax = uplt.subplots() >>> ax.format(ticklen=5, metalinewidth=2) """ # Add input dictionaries diff --git a/ultraplot/constructor.py b/ultraplot/constructor.py index bef70e118..4ed08cdc8 100644 --- a/ultraplot/constructor.py +++ b/ultraplot/constructor.py @@ -994,8 +994,8 @@ def Locator(locator, *args, discrete=False, **kwargs): of the "registered" locators (see below table). If `locator` is a list or tuple and the first element is a "registered" locator name, subsequent elements are passed to the locator class as positional - arguments. For example, ``pplt.Locator(('multiple', 5))`` is - equivalent to ``pplt.Locator('multiple', 5)``. + arguments. For example, ``uplt.Locator(('multiple', 5))`` is + equivalent to ``uplt.Locator('multiple', 5)``. .. _locator_table: @@ -1132,7 +1132,7 @@ def Formatter(formatter, *args, date=False, index=False, **kwargs): "registered" formatters or formatter presets (see below table). If `formatter` is a list or tuple and the first element is a "registered" formatter name, subsequent elements are passed to the formatter class - as positional arguments. For example, ``pplt.Formatter(('sigfig', 3))`` is + as positional arguments. For example, ``uplt.Formatter(('sigfig', 3))`` is equivalent to ``Formatter('sigfig', 3)``. diff --git a/ultraplot/figure.py b/ultraplot/figure.py index cedc5e73e..b89f00f32 100644 --- a/ultraplot/figure.py +++ b/ultraplot/figure.py @@ -198,12 +198,12 @@ two options: * Pass a *list* of projection specifications, one for each subplot. - For example, ``pplt.subplots(ncols=2, proj=('cart', 'robin'))``. + For example, ``uplt.subplots(ncols=2, proj=('cart', 'robin'))``. * Pass a *dictionary* of projection specifications, where the keys are integers or tuples of integers that indicate the projection to use for the corresponding subplot number(s). If a key is not provided, the default projection ``'cartesian'`` is used. For example, - ``pplt.subplots(ncols=4, proj={2: 'cyl', (3, 4): 'stere'})`` creates + ``uplt.subplots(ncols=4, proj={2: 'cyl', (3, 4): 'stere'})`` creates a figure with a default Cartesian axes for the first subplot, a Mercator projection for the second subplot, and a Stereographic projection for the third and fourth subplots. @@ -211,7 +211,7 @@ %(axes.proj_kw)s If dictionary of properties, applies globally. If list or dictionary of dictionaries, applies to specific subplots, as with `proj`. For example, - ``pplt.subplots(ncols=2, proj='cyl', proj_kw=({'lon_0': 0}, {'lon_0': 180})`` + ``uplt.subplots(ncols=2, proj='cyl', proj_kw=({'lon_0': 0}, {'lon_0': 180})`` centers the projection in the left subplot on the prime meridian and in the right subplot on the international dateline. %(axes.backend)s @@ -488,14 +488,14 @@ class Figure(mfigure.Figure): ) _space_message = ( "To set the left, right, bottom, top, wspace, or hspace gridspec values, " - "pass them as keyword arguments to pplt.figure() or pplt.subplots(). Please " + "pass them as keyword arguments to uplt.figure() or uplt.subplots(). Please " "note they are now specified in physical units, with strings interpreted by " - "pplt.units() and floats interpreted as font size-widths." + "uplt.units() and floats interpreted as font size-widths." ) _tight_message = ( "ultraplot uses its own tight layout algorithm that is activated by default. " - "To disable it, set pplt.rc['subplots.tight'] to False or pass tight=False " - "to pplt.subplots(). For details, see fig.auto_layout()." + "To disable it, set uplt.rc['subplots.tight'] to False or pass tight=False " + "to uplt.subplots(). For details, see fig.auto_layout()." ) _warn_interactive = True # disabled after first warning @@ -517,7 +517,7 @@ def __repr__(self): @docstring._obfuscate_kwargs @docstring._snippet_manager @warnings._rename_kwargs( - "0.7.0", axpad="innerpad", autoformat="pplt.rc.autoformat = {}" + "0.7.0", axpad="innerpad", autoformat="uplt.rc.autoformat = {}" ) def __init__( self, @@ -658,7 +658,7 @@ def __init__( # Add space settings # NOTE: This is analogous to 'subplotpars' but we don't worry about # user mutability. Think it's perfectly fine to ask users to simply - # pass these to pplt.figure() or pplt.subplots(). Also overriding + # pass these to uplt.figure() or uplt.subplots(). Also overriding # 'subplots_adjust' would be confusing since we switch to absolute # units and that function is heavily used outside of ultraplot. params = { @@ -1561,7 +1561,7 @@ def _align_content(): # noqa: E306 _align_content() @warnings._rename_kwargs( - "0.10.0", mathtext_fallback="pplt.rc.mathtext_fallback = {}" + "0.10.0", mathtext_fallback="uplt.rc.mathtext_fallback = {}" ) @docstring._snippet_manager def format( diff --git a/ultraplot/gridspec.py b/ultraplot/gridspec.py index 44e79d3e4..105f90c33 100644 --- a/ultraplot/gridspec.py +++ b/ultraplot/gridspec.py @@ -1470,8 +1470,8 @@ def __getitem__(self, key): Example ------- - >>> import ultraplot as pplt - >>> fig, axs = pplt.subplots(nrows=3, ncols=3) + >>> import ultraplot as uplt + >>> fig, axs = uplt.subplots(nrows=3, ncols=3) >>> axs[5] # the subplot in the second row, third column >>> axs[1, 2] # the subplot in the second row, third column >>> axs[:, 0] # a SubplotGrid containing the subplots in the first column diff --git a/ultraplot/internals/docstring.py b/ultraplot/internals/docstring.py index 09e07b900..f414942d4 100644 --- a/ultraplot/internals/docstring.py +++ b/ultraplot/internals/docstring.py @@ -4,7 +4,7 @@ """ # WARNING: To check every docstring in the package for # unfilled snippets simply use the following code: -# >>> import ultraplot as pplt +# >>> import ultraplot as uplt # ... seen = set() # ... def _iter_doc(objs): # ... if objs in seen: @@ -19,7 +19,7 @@ # ... if obj.__doc__ and '%(' in obj.__doc__: # ... yield obj.__name__ # ... yield from _iter_doc(obj) -# ... print(*_iter_doc(pplt)) +# ... print(*_iter_doc(uplt)) import inspect import re diff --git a/ultraplot/scale.py b/ultraplot/scale.py index bce15b00b..f2e96787c 100644 --- a/ultraplot/scale.py +++ b/ultraplot/scale.py @@ -798,11 +798,11 @@ def __init__(self, *args): Example ------- - >>> import ultraplot as pplt + >>> import ultraplot as uplt >>> import numpy as np - >>> scale = pplt.CutoffScale(10, 0.5) # move slower above 10 - >>> scale = pplt.CutoffScale(10, 2, 20) # move faster between 10 and 20 - >>> scale = pplt.CutoffScale(10, np.inf, 20) # jump from 10 to 20 + >>> scale = uplt.CutoffScale(10, 0.5) # move slower above 10 + >>> scale = uplt.CutoffScale(10, 2, 20) # move faster between 10 and 20 + >>> scale = uplt.CutoffScale(10, np.inf, 20) # jump from 10 to 20 """ # NOTE: See https://stackoverflow.com/a/5669301/4970632 super().__init__() diff --git a/ultraplot/tests/test_1dplots.py b/ultraplot/tests/test_1dplots.py index bc421f37f..f5664d2d9 100644 --- a/ultraplot/tests/test_1dplots.py +++ b/ultraplot/tests/test_1dplots.py @@ -6,7 +6,7 @@ import numpy.ma as ma import pandas as pd -import ultraplot as pplt +import ultraplot as uplt import pytest state = np.random.RandomState(51423) @@ -20,7 +20,7 @@ def test_auto_reverse(): x = np.arange(10)[::-1] y = np.arange(10) z = state.rand(10, 10) - fig, axs = pplt.subplots(ncols=2, nrows=3, share=0) + fig, axs = uplt.subplots(ncols=2, nrows=3, share=0) # axs[0].format(xreverse=False) # should fail axs[0].plot(x, y) axs[1].format(xlim=(0, 9)) # manual override @@ -40,7 +40,7 @@ def test_cmap_cycles(): """ Test sampling of multiple continuous colormaps. """ - cycle = pplt.Cycle( + cycle = uplt.Cycle( "Boreal", "Grays", "Fire", @@ -50,7 +50,7 @@ def test_cmap_cycles(): right=[0.6] * 5, samples=[3, 4, 5, 2, 1], ) - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() data = state.rand(10, len(cycle)).cumsum(axis=1) data = pd.DataFrame(data, columns=list("abcdefghijklmno")) ax.plot(data, cycle=cycle, linewidth=2, legend="b") @@ -62,7 +62,7 @@ def test_column_iteration(): """ Test scatter column iteration. """ - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) axs[0].plot(state.rand(5, 5), state.rand(5, 5), lw=5) axs[1].scatter( state.rand(5, 5), state.rand(5, 5), state.rand(5, 5), state.rand(5, 5) @@ -84,7 +84,7 @@ def test_bar_width(): """ Test relative and absolute widths. """ - fig, axs = pplt.subplots(ncols=3) + fig, axs = uplt.subplots(ncols=3) x = np.arange(10) y = state.rand(10, 2) for i, ax in enumerate(axs): @@ -98,7 +98,7 @@ def test_bar_vectors(): Test vector arguments to bar plots. """ facecolors = np.repeat(0.1, 3) * np.arange(1, 11)[:, None] - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.bar( np.arange(10), np.arange(1, 11), @@ -115,7 +115,7 @@ def test_boxplot_colors(): """ Test box colors and cycle colors. """ - fig = pplt.figure(share=False) + fig = uplt.figure(share=False) ax = fig.subplot(221) box_data = state.uniform(-3, 3, size=(1000, 5)) violin_data = state.normal(0, 1, size=(1000, 5)) @@ -149,7 +149,7 @@ def test_boxplot_vectors(): datas.append(data) datas = np.array(datas, dtype=object) assert len(datas) == len(coords) - fig, ax = pplt.subplot(refwidth=3) + fig, ax = uplt.subplot(refwidth=3) ax.boxplot( coords, datas, @@ -170,7 +170,7 @@ def test_histogram_types(): """ Test the different histogram types using basic keywords. """ - fig, axs = pplt.subplots(ncols=2, nrows=2, share=False) + fig, axs = uplt.subplots(ncols=2, nrows=2, share=False) data = state.normal(size=(100, 5)) data += np.arange(5) kws = ({"stack": 0}, {"stack": 1}, {"fill": 0}, {"fill": 1, "alpha": 0.5}) @@ -184,7 +184,7 @@ def test_invalid_plot(): """ Test lines with missing or invalid values. """ - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) data = state.normal(size=(100, 5)) for j in range(5): data[:, j] = np.sort(data[:, j]) @@ -201,7 +201,7 @@ def test_invalid_dist(): """ Test distributions with missing or invalid data. """ - fig, axs = pplt.subplots(ncols=2, nrows=2) + fig, axs = uplt.subplots(ncols=2, nrows=2) data = state.normal(size=(100, 5)) for i in range(5): # test uneven numbers of invalid values data[: 10 * (i + 1), :] = np.nan @@ -218,11 +218,11 @@ def test_pie_charts(): """ Test basic pie plots. No examples in user guide right now. """ - pplt.rc.inlinefmt = "svg" + uplt.rc.inlinefmt = "svg" labels = ["foo", "bar", "baz", "biff", "buzz"] array = np.arange(1, 6) data = pd.Series(array, index=labels) - fig = pplt.figure() + fig = uplt.figure() ax = fig.subplot(121) ax.pie(array, edgefix=True, labels=labels, ec="k", cycle="reds") ax = fig.subplot(122) @@ -236,8 +236,8 @@ def test_parametric_labels(): Test passing strings as parametric 'color values'. This is likely a common use case. """ - pplt.rc.inlinefmt = "svg" - fig, ax = pplt.subplots() + uplt.rc.inlinefmt = "svg" + fig, ax = uplt.subplots() ax.parametric( state.rand(5), c=list("abcde"), lw=20, colorbar="b", cmap_kw={"left": 0.2} ) @@ -250,7 +250,7 @@ def test_parametric_colors(): Test color input arguments. Should be able to make monochromatic plots for case where we want `line` without sticky x/y edges. """ - fig, axs = pplt.subplots(ncols=2, nrows=2) + fig, axs = uplt.subplots(ncols=2, nrows=2) colors = ( [(0, 1, 1), (0, 1, 0), (1, 0, 0), (0, 0, 1), (1, 1, 0)], ["b", "r", "g", "m", "c", "y"], @@ -277,13 +277,13 @@ def test_scatter_args(): """ x, y = state.randn(50), state.randn(50) data = state.rand(50, 3) - fig, axs = pplt.subplots(ncols=4, share=0) + fig, axs = uplt.subplots(ncols=4, share=0) ax = axs[0] ax.scatter(x, y, s=80, fc="none", edgecolors="r") ax = axs[1] ax.scatter(data, c=data, cmap="reds") # column iteration ax = axs[2] - with pytest.warns(pplt.internals.UltraplotWarning) as record: + with pytest.warns(uplt.internals.UltraplotWarning) as record: ax.scatter(data[:, 0], c=data, cmap="reds") # actual colors assert len(record) == 1 ax = axs[3] @@ -297,7 +297,7 @@ def test_scatter_inbounds(): """ Test in-bounds scatter plots. """ - fig, axs = pplt.subplots(ncols=2, share=False) + fig, axs = uplt.subplots(ncols=2, share=False) N = 100 fig.format(xlim=(0, 20)) for i, ax in enumerate(axs): @@ -311,7 +311,7 @@ def test_scatter_alpha(): """ Test behavior with multiple alpha values. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() data = state.rand(10) alpha = np.linspace(0.1, 1, data.size) ax.scatter(data, alpha=alpha) @@ -326,8 +326,8 @@ def test_scatter_cycle(): """ Test scatter property cycling. """ - fig, ax = pplt.subplots() - cycle = pplt.Cycle( + fig, ax = uplt.subplots() + cycle = uplt.Cycle( "538", marker=["X", "o", "s", "d"], sizes=[20, 100], edgecolors=["r", "k"] ) ax.scatter( @@ -346,8 +346,8 @@ def test_scatter_sizes(): """ # Compare setting size to input size size = 20 - with pplt.rc.context({"lines.markersize": size}): - fig = pplt.figure() + with uplt.rc.context({"lines.markersize": size}): + fig = uplt.figure() ax = fig.subplot(121, margin=0.15) for i in range(3): kw = {"absolute_size": i == 2} diff --git a/ultraplot/tests/test_2dplots.py b/ultraplot/tests/test_2dplots.py index b25c08020..5ae805a4a 100644 --- a/ultraplot/tests/test_2dplots.py +++ b/ultraplot/tests/test_2dplots.py @@ -6,7 +6,7 @@ import pytest import xarray as xr -import ultraplot as pplt +import ultraplot as uplt state = np.random.RandomState(51423) @@ -17,7 +17,7 @@ def test_colormap_vcenter(): """ Test colormap vcenter. """ - fig, axs = pplt.subplots(ncols=3) + fig, axs = uplt.subplots(ncols=3) data = 10 * state.rand(10, 10) - 3 axs[0].pcolor(data, vcenter=0) axs[1].pcolor(data, vcenter=1) @@ -31,7 +31,7 @@ def test_auto_diverging1(): Test that auto diverging works. """ # Test with basic data - fig = pplt.figure() + fig = uplt.figure() # fig.format(collabels=('Auto sequential', 'Auto diverging'), suptitle='Default') ax = fig.subplot(121) ax.pcolor(state.rand(10, 10) * 5, colorbar="b") @@ -45,7 +45,7 @@ def test_auto_diverging1(): @pytest.mark.mpl_image_compare def test_autodiverging2(): # Test with explicit vcenter - fig, axs = pplt.subplots(ncols=3) + fig, axs = uplt.subplots(ncols=3) data = 5 * state.rand(10, 10) axs[0].pcolor(data, vcenter=0, colorbar="b") # otherwise should be disabled axs[1].pcolor(data, vcenter=1.5, colorbar="b") @@ -56,22 +56,22 @@ def test_autodiverging2(): @pytest.mark.mpl_image_compare def test_autodiverging3(): # Test when cmap input disables auto diverging. - fig, axs = pplt.subplots(ncols=2, nrows=2, refwidth=2) - cmap = pplt.Colormap( + fig, axs = uplt.subplots(ncols=2, nrows=2, refwidth=2) + cmap = uplt.Colormap( ("red7", "red3", "red1", "blue1", "blue3", "blue7"), listmode="discrete" ) # noqa: E501 data1 = 10 * state.rand(10, 10) data2 = data1 - 2 for i, cmap in enumerate(("RdBu_r", cmap)): for j, data in enumerate((data1, data2)): - cmap = pplt.Colormap(pplt.Colormap(cmap)) + cmap = uplt.Colormap(uplt.Colormap(cmap)) axs[i, j].pcolormesh(data, cmap=cmap, colorbar="b") return fig @pytest.mark.mpl_image_compare def test_autodiverging4(): - fig, axs = pplt.subplots(ncols=3) + fig, axs = uplt.subplots(ncols=3) data = state.rand(5, 5) * 10 - 5 for i, ax in enumerate(axs[:2]): ax.pcolor(data, sequential=bool(i), colorbar="b") @@ -81,7 +81,7 @@ def test_autodiverging4(): @pytest.mark.mpl_image_compare def test_autodiverging5(): - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) data = state.rand(5, 5) * 10 + 2 for ax, norm in zip(axs, (None, "div")): ax.pcolor(data, norm=norm, colorbar="b") @@ -93,11 +93,11 @@ def test_colormap_mode(): """ Test auto extending, auto discrete. Should issue warnings. """ - fig, axs = pplt.subplots(ncols=2, nrows=2, share=False) + fig, axs = uplt.subplots(ncols=2, nrows=2, share=False) axs[0].pcolor(state.rand(5, 5) % 0.3, extend="both", cyclic=True, colorbar="b") axs[1].pcolor(state.rand(5, 5), sequential=True, diverging=True, colorbar="b") axs[2].pcolor(state.rand(5, 5), discrete=False, qualitative=True, colorbar="b") - pplt.rc["cmap.discrete"] = False # should be ignored below + uplt.rc["cmap.discrete"] = False # should be ignored below axs[3].contourf(state.rand(5, 5), colorbar="b") return fig @@ -111,7 +111,7 @@ def test_contour_labels(): behavior when labels are active. """ data = state.rand(5, 5) * 10 - 5 - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) ax = axs[0] ax.contourf( data, @@ -134,7 +134,7 @@ def test_contour_negative(): """ Ensure `cmap.monochrome` properly assigned. """ - fig = pplt.figure(share=False) + fig = uplt.figure(share=False) ax = fig.subplot(131) data = state.rand(10, 10) * 10 - 5 ax.contour(data, color="k") @@ -153,7 +153,7 @@ def test_contour_single(): da = xr.DataArray( np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]), dims=["y", "x"] ) - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.contour(da, levels=[5.0], color="r") return fig @@ -165,8 +165,8 @@ def test_edge_fix(): """ # Test basic application # TODO: This should make no difference for PNG plots? - pplt.rc.edgefix = 1 - fig, axs = pplt.subplots(ncols=2, share=False) + uplt.rc.edgefix = 1 + fig, axs = uplt.subplots(ncols=2, share=False) axs.format(grid=False) axs[0].bar( state.rand( @@ -182,10 +182,10 @@ def test_edge_fix(): # Test whether ignored for transparent colorbars data = state.rand(10, 10) cmap = "magma" - fig, axs = pplt.subplots(nrows=3, ncols=2, refwidth=2.5, share=False) + fig, axs = uplt.subplots(nrows=3, ncols=2, refwidth=2.5, share=False) for i, iaxs in enumerate((axs[:2], axs[2:4])): if i == 0: - cmap = pplt.Colormap("magma", alpha=0.5) + cmap = uplt.Colormap("magma", alpha=0.5) alpha = None iaxs.format(title="Colormap alpha") else: @@ -205,11 +205,11 @@ def test_flow_functions(): These are seldom used and missing from documentation. Be careful not to break anything basic. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() for _ in range(2): ax.streamplot(state.rand(10, 10), 5 * state.rand(10, 10), label="label") - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) ax = axs[0] ax.quiver( state.rand(10, 10), 5 * state.rand(10, 10), c=state.rand(10, 10), label="label" @@ -224,9 +224,9 @@ def test_gray_adjustment(): """ Test gray adjustments when creating segmented colormaps. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() data = state.rand(5, 5) * 10 - 5 - cmap = pplt.Colormap(["blue", "grey3", "red"]) + cmap = uplt.Colormap(["blue", "grey3", "red"]) ax.pcolor(data, cmap=cmap, colorbar="b") return fig @@ -236,10 +236,10 @@ def test_ignore_message(): """ Test various ignored argument warnings. """ - warning = pplt.internals.UltraplotWarning - fig, axs = pplt.subplots(ncols=2, nrows=2) + warning = uplt.internals.UltraplotWarning + fig, axs = uplt.subplots(ncols=2, nrows=2) with pytest.warns(warning): - axs[0].contour(state.rand(5, 5) * 10, levels=pplt.arange(10), symmetric=True) + axs[0].contour(state.rand(5, 5) * 10, levels=uplt.arange(10), symmetric=True) with pytest.warns(warning): axs[1].contourf( state.rand(10, 10), levels=np.linspace(0, 1, 10), locator=5, locator_kw={} @@ -247,7 +247,7 @@ def test_ignore_message(): with pytest.warns(warning): axs[2].contourf( state.rand(10, 10), - levels=pplt.arange(0, 1, 0.2), + levels=uplt.arange(0, 1, 0.2), vmin=0, vmax=2, locator=3, @@ -257,7 +257,7 @@ def test_ignore_message(): axs[3].hexbin( state.rand(1000), state.rand(1000), - levels=pplt.arange(0, 20), + levels=uplt.arange(0, 20), gridsize=10, locator=2, colorbar="b", @@ -277,7 +277,7 @@ def test_levels_with_vmin_vmax(): data = state.rand(y.size, x.size) # Figure - fig = pplt.figure(refwidth=2.3, share=False) + fig = uplt.figure(refwidth=2.3, share=False) axs = fig.subplots() m = axs.pcolormesh(x, y, data, vmax=1.35123) axs.colorbar([m], loc="r") @@ -289,7 +289,7 @@ def test_level_restriction(): """ Test `negative`, `positive`, and `symmetric` with and without discrete. """ - fig, axs = pplt.subplots(ncols=3, nrows=2) + fig, axs = uplt.subplots(ncols=3, nrows=2) data = 20 * state.rand(10, 10) - 5 keys = ("negative", "positive", "symmetric") for i, grp in enumerate((axs[:3], axs[3:])): @@ -305,9 +305,9 @@ def test_qualitative_colormaps_1(): Test both `colors` and `cmap` input and ensure extend setting is used for extreme only if unset. """ - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) data = state.rand(5, 5) - colors = pplt.get_colors("set3") + colors = uplt.get_colors("set3") for ax, extend in zip(axs, ("both", "neither")): ax.pcolor(data, extend=extend, colors=colors, colorbar="b") return fig @@ -315,9 +315,9 @@ def test_qualitative_colormaps_1(): @pytest.mark.mpl_image_compare def test_qualitative_colormaps_2(): - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) data = state.rand(5, 5) - cmap = pplt.Colormap("set3") + cmap = uplt.Colormap("set3") cmap.set_under("black") # does not overwrite for ax, extend in zip(axs, ("both", "neither")): ax.pcolor(data, extend=extend, cmap=cmap, colorbar="b") @@ -329,7 +329,7 @@ def test_segmented_norm(): """ Test segmented norm with non-discrete levels. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.pcolor( state.rand(5, 5) * 10, discrete=False, @@ -345,7 +345,7 @@ def test_triangular_functions(): """ Test triangular functions. Here there is no remotely sensible way to infer """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() N = 30 y = state.rand(N) * 20 x = state.rand(N) * 50 diff --git a/ultraplot/tests/test_axes.py b/ultraplot/tests/test_axes.py index 9d5d534af..f73bad44c 100644 --- a/ultraplot/tests/test_axes.py +++ b/ultraplot/tests/test_axes.py @@ -4,14 +4,14 @@ """ import numpy as np import pytest -import ultraplot as pplt +import ultraplot as uplt state = np.random.RandomState(51423) def test_axis_access(): # attempt to access the ax object 2d and linearly - fix, ax = pplt.subplots(ncols=2, nrows=2) + fix, ax = uplt.subplots(ncols=2, nrows=2) ax[0, 0] ax[1, 0] with pytest.raises(IndexError): @@ -24,7 +24,7 @@ def test_inset_colors_1(): """ Test color application for zoom boxes. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.format(xlim=(0, 100), ylim=(0, 100)) ix = ax.inset_axes( (0.5, 0.5, 0.3, 0.3), zoom=True, zoom_kw={"color": "r", "fc": "r", "ec": "b"} @@ -36,12 +36,12 @@ def test_inset_colors_1(): @pytest.mark.mpl_image_compare def test_inset_colors_2(): - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.format(xlim=(0, 100), ylim=(0, 100)) ix = ax.inset_axes( (0.3, 0.5, 0.5, 0.3), zoom=True, - zoom_kw={"lw": 3, "ec": "red9", "a": 1, "c": pplt.set_alpha("red4", 0.5)}, + zoom_kw={"lw": 3, "ec": "red9", "a": 1, "c": uplt.set_alpha("red4", 0.5)}, ) ix.format(xlim=(10, 20), ylim=(10, 20)) return fig @@ -53,7 +53,7 @@ def test_inset_zoom_update(): Test automatic limit adjusment with successive changes. Without the extra lines in `draw()` and `get_tight_bbox()` this fails. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.format(xlim=(0, 100), ylim=(0, 100)) ix = ax.inset_axes((40, 40, 20, 20), zoom=True, transform="data") ix.format(xlim=(10, 20), ylim=(10, 20), grid=False) @@ -67,7 +67,7 @@ def test_panels_with_sharing(): """ Previously the below text would hide the second y label. """ - fig, axs = pplt.subplots(ncols=2, share=False, refwidth=1.5) + fig, axs = uplt.subplots(ncols=2, share=False, refwidth=1.5) axs.panel("left") fig.format(ylabel="ylabel", xlabel="xlabel") return fig @@ -79,7 +79,7 @@ def test_panels_without_sharing_1(): What should happen if `share=False` but figure-wide sharing enabled? Strange use case but behavior appears "correct." """ - fig, axs = pplt.subplots(ncols=2, share=True, refwidth=1.5, includepanels=False) + fig, axs = uplt.subplots(ncols=2, share=True, refwidth=1.5, includepanels=False) axs.panel("left", share=False) fig.format(ylabel="ylabel", xlabel="xlabel") return fig @@ -87,7 +87,7 @@ def test_panels_without_sharing_1(): @pytest.mark.mpl_image_compare def test_panels_without_sharing_2(): - fig, axs = pplt.subplots(ncols=2, refwidth=1.5, includepanels=True) + fig, axs = uplt.subplots(ncols=2, refwidth=1.5, includepanels=True) for _ in range(3): p = axs[0].panel("l", space=0) p.format(xlabel="label") @@ -103,7 +103,7 @@ def test_panels_suplabels_three_hor_panels(): Include here centers the x label to include the panels The xlabel should be centered along the main plot with the included side panels """ - fig = pplt.figure() + fig = uplt.figure() ax = fig.subplots(refwidth=1.5, includepanels=True) for _ in range(3): ax[0].panel("l") @@ -117,7 +117,7 @@ def test_panels_suplabels_three_hor_panels_donotinlcude(): Test for 1 subplot with 3 left panels The xlabel should be centered on the main plot """ - fig = pplt.figure() + fig = uplt.figure() ax = fig.subplots(refwidth=1.5, includepanels=False) for _ in range(3): ax[0].panel("l") @@ -135,7 +135,7 @@ def test_twin_axes_1(): Adjust twin axis positions. Should allow easily switching the location. """ # Test basic twin creation and tick, spine, label location changes - fig = pplt.figure() + fig = uplt.figure() ax = fig.subplot() ax.format( ycolor="blue", @@ -155,7 +155,7 @@ def test_twin_axes_1(): def test_twin_axes_2(): # Simple example but doesn't quite work. Figure out how to specify left vs. right # spines for 'offset' locations... maybe needs another keyword. - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.format(ymax=10, ylabel="Reference") ax.alty(color="green", label="Green", max=8) ax.alty(color="red", label="Red", max=15, loc=("axes", -0.2)) @@ -167,7 +167,7 @@ def test_twin_axes_2(): def test_twin_axes_3(): # A worked example from Riley Brady # Uses auto-adjusting limits - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() axs = [ax, ax.twinx(), ax.twinx()] axs[-1].spines["right"].set_position(("axes", 1.2)) colors = ("Green", "Red", "Blue") diff --git a/ultraplot/tests/test_colorbar.py b/ultraplot/tests/test_colorbar.py index 9c7efe18c..9a02947ad 100644 --- a/ultraplot/tests/test_colorbar.py +++ b/ultraplot/tests/test_colorbar.py @@ -4,7 +4,7 @@ """ import numpy as np import pytest -import ultraplot as pplt +import ultraplot as uplt state = np.random.RandomState(51423) @@ -14,7 +14,7 @@ def test_outer_align(): """ Test various align options. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.plot(np.empty((0, 4)), labels=list("abcd")) ax.legend(loc="bottom", align="right", ncol=2) ax.legend(loc="left", align="bottom", ncol=1) @@ -41,7 +41,7 @@ def test_colorbar_ticks(): """ Test ticks modification. """ - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) ax = axs[0] ax.colorbar("magma", loc="bottom", ticklen=10, linewidth=3, tickminor=True) ax = axs[1] @@ -56,9 +56,9 @@ def test_discrete_ticks(): """ Test `DiscreteLocator`. """ - levels = pplt.arange(0, 2, 0.1) + levels = uplt.arange(0, 2, 0.1) data = state.rand(5, 5) * 2 - fig, axs = pplt.subplots(share=False, ncols=2, nrows=2, refwidth=2) + fig, axs = uplt.subplots(share=False, ncols=2, nrows=2, refwidth=2) for i, ax in enumerate(axs): cmd = ax.contourf if i // 2 == 0 else ax.pcolormesh m = cmd(data, levels=levels, extend="both") @@ -73,7 +73,7 @@ def test_discrete_vs_fixed(): Test `DiscreteLocator` for numeric on-the-fly mappable ticks and `FixedLocator` otherwise. """ - fig, axs = pplt.subplots(ncols=2, nrows=3, refwidth=1.3, share=False) + fig, axs = uplt.subplots(ncols=2, nrows=3, refwidth=1.3, share=False) axs[0].plot(state.rand(10, 5), labels=list("xyzpq"), colorbar="b") # fixed axs[1].plot(state.rand(10, 5), labels=np.arange(5), colorbar="b") # discrete axs[2].contourf( @@ -86,7 +86,7 @@ def test_discrete_vs_fixed(): state.rand(10, 10) * 20, colorbar="b", levels=[0, 2, 4, 6, 8, 10, 15, 20] ) # fixed axs[5].pcolormesh( - state.rand(10, 10) * 20, colorbar="b", levels=pplt.arange(0, 20, 2) + state.rand(10, 10) * 20, colorbar="b", levels=uplt.arange(0, 20, 2) ) # discrete return fig @@ -114,9 +114,9 @@ def test_uneven_levels(): "violet1", "violet3", ] - levels_even = pplt.arange(1, 12, 1) + levels_even = uplt.arange(1, 12, 1) levels_uneven = [1.0, 1.25, 1.5, 2.0, 2.5, 3.0, 3.75, 4.5, 6.0, 7.5, 9.0, 12.0] - fig, axs = pplt.subplots(ncols=2, refwidth=3.0) + fig, axs = uplt.subplots(ncols=2, refwidth=3.0) axs[0].pcolor( data, levels=levels_uneven, colors=colors, colorbar="r", extend="both" ) @@ -129,7 +129,7 @@ def test_on_the_fly_mappable(): """ Test on-the-fly mappable generation. """ - fig, axs = pplt.subplots(ncols=2, nrows=3, space=3) + fig, axs = uplt.subplots(ncols=2, nrows=3, space=3) axs.format(aspect=0.5) axs[0].colorbar("magma", vmin=None, vmax=100, values=[0, 1, 2, 3, 4], loc="bottom") axs[1].colorbar("magma", vmin=None, vmax=100, loc="bottom") @@ -139,11 +139,11 @@ def test_on_the_fly_mappable(): axs[5].colorbar(["r", "b", "g", "k", "w"], loc="bottom") # Passing labels to plot function. - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.scatter(state.rand(10, 4), labels=["foo", "bar", "baz", "xyz"], colorbar="b") # Passing string value lists. This helps complete the analogy with legend 'labels'. - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() hs = ax.line(state.rand(20, 5)) ax.colorbar(hs, loc="b", values=["abc", "def", "ghi", "pqr", "xyz"]) return fig @@ -155,15 +155,15 @@ def test_inset_colorbars(): Test basic functionality. """ # Simple example - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.colorbar("magma", loc="ul") # Colorbars from lines - fig = pplt.figure(share=False, refwidth=2) + fig = uplt.figure(share=False, refwidth=2) ax = fig.subplot(121) state = np.random.RandomState(51423) data = 1 + (state.rand(12, 10) - 0.45).cumsum(axis=0) - cycle = pplt.Cycle("algae") + cycle = uplt.Cycle("algae") hs = ax.line( data, lw=4, @@ -175,7 +175,7 @@ def test_inset_colorbars(): # Colorbars from a mappable ax = fig.subplot(122) - m = ax.contourf(data.T, extend="both", cmap="algae", levels=pplt.arange(0, 3, 0.5)) + m = ax.contourf(data.T, extend="both", cmap="algae", levels=uplt.arange(0, 3, 0.5)) fig.colorbar( m, loc="r", @@ -206,11 +206,11 @@ def test_segmented_norm_center(): """ Test various align options. """ - fig, ax = pplt.subplots() - cmap = pplt.Colormap("NegPos", cut=0.1) + fig, ax = uplt.subplots() + cmap = uplt.Colormap("NegPos", cut=0.1) data = state.rand(10, 10) * 10 - 2 levels = [-4, -3, -2, -1, 0, 1, 2, 4, 8, 16, 32, 64, 128] - norm = pplt.SegmentedNorm(levels, vcenter=0, fair=1) + norm = uplt.SegmentedNorm(levels, vcenter=0, fair=1) ax.pcolormesh(data, levels=levels, norm=norm, cmap=cmap, colorbar="b") return fig @@ -220,7 +220,7 @@ def test_segmented_norm_ticks(): """ Ensure segmented norm ticks show up in center when `values` are passed. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() data = state.rand(10, 10) * 10 values = (1, 5, 5.5, 6, 10) ax.contourf( @@ -237,7 +237,7 @@ def test_reversed_levels(): """ Test negative levels with a discrete norm and segmented norm. """ - fig, axs = pplt.subplots(ncols=4, nrows=2, refwidth=1.8) + fig, axs = uplt.subplots(ncols=4, nrows=2, refwidth=1.8) data = state.rand(20, 20).cumsum(axis=0) i = 0 for stride in (1, -1): diff --git a/ultraplot/tests/test_docs.py b/ultraplot/tests/test_docs.py index a9bfef526..a54062d79 100644 --- a/ultraplot/tests/test_docs.py +++ b/ultraplot/tests/test_docs.py @@ -52,7 +52,7 @@ # # cartopy tests but keep us from having to dump them. # if baseline == 'test_projections' and VERSION_STRING == 'mpl32': # cell_source = cell_source.replace("'basemap'", "'cartopy'") -# if 'pplt.Proj' in cell_source or 'Table' in cell_source: +# if 'uplt.Proj' in cell_source or 'Table' in cell_source: # return # examples that cannot be naively converted # def run_test(): diff --git a/ultraplot/tests/test_format.py b/ultraplot/tests/test_format.py index 1faad79e8..dad3171f3 100644 --- a/ultraplot/tests/test_format.py +++ b/ultraplot/tests/test_format.py @@ -2,7 +2,7 @@ """ Test format and rc behavior. """ -import locale, numpy as np, ultraplot as pplt, pytest +import locale, numpy as np, ultraplot as uplt, pytest import warnings state = np.random.RandomState(51423) @@ -12,10 +12,10 @@ # """ # Test below line is possible and naming schemes. # """ -# pplt.rc["image.cmap"] = pplt.Colormap("phase", shift=180, left=0.2) -# assert pplt.rc["cmap"] == pplt.rc["cmap.sequential"] == "_Phase_copy_s" -# pplt.rc["image.cmap"] = pplt.Colormap("magma", reverse=True, right=0.8) -# assert pplt.rc["image.cmap"] == pplt.rc["cmap.sequential"] == "_magma_copy_r" +# uplt.rc["image.cmap"] = uplt.Colormap("phase", shift=180, left=0.2) +# assert uplt.rc["cmap"] == uplt.rc["cmap.sequential"] == "_Phase_copy_s" +# uplt.rc["image.cmap"] = uplt.Colormap("magma", reverse=True, right=0.8) +# assert uplt.rc["image.cmap"] == uplt.rc["cmap.sequential"] == "_magma_copy_r" def test_ignored_keywords(): @@ -23,7 +23,7 @@ def test_ignored_keywords(): Test ignored keywords and functions. """ with warnings.catch_warnings(record=True) as record: - fig, ax = pplt.subplots( + fig, ax = uplt.subplots( gridspec_kw={"left": 3}, subplot_kw={"proj": "cart"}, subplotpars={"left": 0.2}, @@ -39,7 +39,7 @@ def test_init_format(): """ Test application of format args on initialization. """ - fig, axs = pplt.subplots( + fig, axs = uplt.subplots( ncols=2, xlim=(0, 10), xlabel="xlabel", @@ -57,7 +57,7 @@ def test_patch_format(): """ Test application of patch args on initialization. """ - fig = pplt.figure(suptitle="Super title") + fig = uplt.figure(suptitle="Super title") fig.subplot( 121, proj="cyl", labels=True, land=True, latlines=20, abcloc="l", abc="[A]" ) @@ -80,7 +80,7 @@ def test_multi_formatting(): """ Support formatting in multiple projections. """ - fig, axs = pplt.subplots(ncols=2, proj=("cart", "cyl")) + fig, axs = uplt.subplots(ncols=2, proj=("cart", "cyl")) axs[0].pcolormesh(state.rand(5, 5)) fig.format( land=1, @@ -106,7 +106,7 @@ def test_inner_title_zorder(): """ Test prominence of contour labels and whatnot. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.format( title="TITLE", titleloc="upper center", titleweight="bold", titlesize="xx-large" ) @@ -140,7 +140,7 @@ def test_font_adjustments(): """ Test font name application. Somewhat hard to do. """ - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) axs.format( abc="A.", fontsize=15, @@ -159,7 +159,7 @@ def test_axes_colors(): """ Test behavior of passing color to format. """ - fig, axs = pplt.subplots( + fig, axs = uplt.subplots( ncols=3, nrows=2, share=False, @@ -195,21 +195,21 @@ def test_locale_formatting(loc): # Your test code that is sensitive to the locale settings assert locale.getlocale() == (loc.split(".")[0], loc.split(".")[1]) - pplt.rc["formatter.use_locale"] = False - pplt.rc["formatter.zerotrim"] = True - with pplt.rc.context({"formatter.use_locale": True}): - fig, ax = pplt.subplots() - ticks = pplt.arange(-1, 1, 0.1) + uplt.rc["formatter.use_locale"] = False + uplt.rc["formatter.zerotrim"] = True + with uplt.rc.context({"formatter.use_locale": True}): + fig, ax = uplt.subplots() + ticks = uplt.arange(-1, 1, 0.1) ax.format(ylim=(min(ticks), max(ticks)), yticks=ticks) return fig finally: # Always reset to the original locale locale.setlocale(locale.LC_ALL, original_locale) - pplt.rc["formatter.use_locale"] = False - pplt.rc["formatter.zerotrim"] = True - with pplt.rc.context({"formatter.use_locale": True}): - fig, ax = pplt.subplots() - ticks = pplt.arange(-1, 1, 0.1) + uplt.rc["formatter.use_locale"] = False + uplt.rc["formatter.zerotrim"] = True + with uplt.rc.context({"formatter.use_locale": True}): + fig, ax = uplt.subplots() + ticks = uplt.arange(-1, 1, 0.1) ax.format(ylim=(min(ticks), max(ticks)), yticks=ticks) return fig @@ -220,7 +220,7 @@ def test_bounds_ticks(): Test spine bounds and location. Previously applied `fixticks` automatically but no longer the case. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() # ax.format(xlim=(-10, 10)) ax.format(xloc="top") ax.format(xlim=(-10, 15), xbounds=(0, 10)) @@ -232,7 +232,7 @@ def test_cutoff_ticks(): """ Test spine cutoff ticks. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() # ax.format(xlim=(-10, 10)) ax.format(xlim=(-10, 10), xscale=("cutoff", 0, 2), xloc="top", fixticks=True) ax.axvspan(0, 100, facecolor="k", alpha=0.1) @@ -244,8 +244,8 @@ def test_spine_side(): """ Test automatic spine selection when passing `xspineloc` or `yspineloc`. """ - fig, ax = pplt.subplots() - ax.plot(pplt.arange(-5, 5), (10 * state.rand(11, 5) - 5).cumsum(axis=0)) + fig, ax = uplt.subplots() + ax.plot(uplt.arange(-5, 5), (10 * state.rand(11, 5) - 5).cumsum(axis=0)) ax.format(xloc="bottom", yloc="zero") ax.alty(loc="right") return fig @@ -256,7 +256,7 @@ def test_spine_offset(): """ Test offset axes. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.format(xloc="none") # test none instead of neither ax.alty(loc=("axes", -0.2), color="red") # ax.alty(loc=('axes', 1.2), color='blue') @@ -270,7 +270,7 @@ def test_tick_direction(): """ Test tick direction arguments. """ - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) axs[0].format(tickdir="in") axs[1].format(xtickdirection="inout", ytickdir="out") # rc setting should be used? return fig @@ -281,7 +281,7 @@ def test_tick_length(): """ Test tick length args. Ensure ratios can be applied successively. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.format(yticklen=100) ax.format(xticklen=50, yticklenratio=0.1) return fig @@ -294,7 +294,7 @@ def test_tick_width(): width to `zero` adjusts length for label padding, and ticks can appear without spines if requested. """ - fig, axs = pplt.subplots(ncols=2, nrows=2, share=False) + fig, axs = uplt.subplots(ncols=2, nrows=2, share=False) ax = axs[0] ax.format(linewidth=2, ticklen=20, xtickwidthratio=1) ax.format(ytickwidthratio=0.3) @@ -316,7 +316,7 @@ def test_tick_labels(): data = state.rand(5, 3) data = pd.DataFrame(data, index=["foo", "bar", "baz", "bat", "bot"]) - fig, axs = pplt.subplots(abc="A.", abcloc="ul", ncols=2, refwidth=3, span=False) + fig, axs = uplt.subplots(abc="A.", abcloc="ul", ncols=2, refwidth=3, span=False) for i, ax in enumerate(axs): data.index.name = "label" if i == 1: @@ -334,7 +334,7 @@ def test_label_settings(): """ Test label colors and ensure color change does not erase labels. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.format(xlabel="xlabel", ylabel="ylabel") ax.format(labelcolor="red") return fig diff --git a/ultraplot/tests/test_geographic.py b/ultraplot/tests/test_geographic.py index c2f6a3265..3bec70b67 100644 --- a/ultraplot/tests/test_geographic.py +++ b/ultraplot/tests/test_geographic.py @@ -6,8 +6,8 @@ def test_geographic_single_projection(): fig = plt.figure(refwidth=3) axs = fig.subplots(nrows=2, proj="robin", proj_kw={"lon_0": 180}) - # proj = pplt.Proj('robin', lon_0=180) - # axs = pplt.subplots(nrows=2, proj=proj) # equivalent to above + # proj = uplt.Proj('robin', lon_0=180) + # axs = uplt.subplots(nrows=2, proj=proj) # equivalent to above axs.format( suptitle="Figure with single projection", land=True, diff --git a/ultraplot/tests/test_inset.py b/ultraplot/tests/test_inset.py index b454fcfd1..ea1bf76af 100644 --- a/ultraplot/tests/test_inset.py +++ b/ultraplot/tests/test_inset.py @@ -1,12 +1,12 @@ -import ultraplot as pplt, numpy as np, pytest +import ultraplot as uplt, numpy as np, pytest @pytest.mark.mpl_image_compare def test_inset_basic(): # Demonstrate that complex arrangements preserve # spacing, aspect ratios, and axis sharing - gs = pplt.GridSpec(nrows=2, ncols=2) - fig = pplt.figure(refwidth=1.5, share=False) + gs = uplt.GridSpec(nrows=2, ncols=2) + fig = uplt.figure(refwidth=1.5, share=False) for ss, side in zip(gs, "tlbr"): ax = fig.add_subplot(ss) px = ax.panel_axes(side, width="3em") diff --git a/ultraplot/tests/test_integration.py b/ultraplot/tests/test_integration.py index 342167a8d..9d63e0e7b 100644 --- a/ultraplot/tests/test_integration.py +++ b/ultraplot/tests/test_integration.py @@ -4,7 +4,7 @@ """ import numpy as np, pandas as pd, seaborn as sns import xarray as xr -import ultraplot as pplt, pytest +import ultraplot as uplt, pytest import pint state = np.random.RandomState(51423) @@ -15,9 +15,9 @@ def test_pint_quantities(): """ Ensure auto-formatting and column iteration both work. """ - pplt.rc.unitformat = "~H" + uplt.rc.unitformat = "~H" ureg = pint.UnitRegistry() - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.plot( np.arange(10), state.rand(10) * ureg.km, @@ -43,7 +43,7 @@ def test_data_keyword(): "y": ("y", np.arange(M) * 5, {"long_name": "latitude"}), }, ) - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() # ax.pcolor('z', data=ds, order='F') ax.pcolor(z="z", data=ds, transpose=True) ax.format(xformatter="deglat", yformatter="deglon") @@ -56,13 +56,13 @@ def test_keep_guide_labels(): Preserve metadata when passing mappables and handles to colorbar and legend subsequently. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() df = pd.DataFrame(state.rand(5, 5)) df.name = "variable" m = ax.pcolor(df) ax.colorbar(m) - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() for k in ("foo", "bar", "baz"): s = pd.Series(state.rand(5), index=list("abcde"), name=k) ax.plot( @@ -85,10 +85,10 @@ def test_seaborn_swarmplot(): Test seaborn swarm plots. """ tips = sns.load_dataset("tips") - fig = pplt.figure(refwidth=3) + fig = uplt.figure(refwidth=3) ax = fig.subplot() sns.swarmplot(ax=ax, x="day", y="total_bill", data=tips, palette="cubehelix") - # fig, ax = pplt.subplots() + # fig, ax = uplt.subplots() # sns.swarmplot(y=state.normal(size=100), ax=ax) return fig @@ -98,7 +98,7 @@ def test_seaborn_hist(): """ Test seaborn histograms. """ - fig, axs = pplt.subplots(ncols=2, nrows=2) + fig, axs = uplt.subplots(ncols=2, nrows=2) sns.histplot(state.normal(size=100), ax=axs[0]) sns.kdeplot(x=state.rand(100), y=state.rand(100), ax=axs[1]) penguins = sns.load_dataset("penguins") @@ -117,7 +117,7 @@ def test_seaborn_relational(): Test scatter plots. Disabling seaborn detection creates mismatch between marker sizes and legend. """ - fig = pplt.figure() + fig = uplt.figure() ax = fig.subplot() sns.set_theme(style="white") # Load the example mpg dataset @@ -144,6 +144,6 @@ def test_seaborn_heatmap(): """ Test seaborn heatmaps. This should work thanks to backwards compatibility support. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() sns.heatmap(state.normal(size=(50, 50)), ax=ax[0]) return fig diff --git a/ultraplot/tests/test_legend.py b/ultraplot/tests/test_legend.py index e38468a31..e91f93b7e 100644 --- a/ultraplot/tests/test_legend.py +++ b/ultraplot/tests/test_legend.py @@ -2,7 +2,7 @@ """ Test legends. """ -import numpy as np, pandas as pd, ultraplot as pplt, pytest +import numpy as np, pandas as pd, ultraplot as uplt, pytest state = np.random.RandomState(51423) @@ -12,7 +12,7 @@ def test_auto_legend(): """ Test retrieval of legends from panels, insets, etc. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.line(state.rand(5, 3), labels=list("abc")) px = ax.panel_axes("right", share=False) px.linex(state.rand(5, 3), labels=list("xyz")) @@ -29,7 +29,7 @@ def test_singleton_legend(): Test behavior when singleton lists are passed. Ensure this does not trigger centered-row legends. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() h1 = ax.plot([0, 1, 2], label="a") h2 = ax.plot([0, 1, 1], label="b") ax.legend(loc="best") @@ -43,7 +43,7 @@ def test_centered_legends(): Test success of algorithm. """ # Basic centered legends - fig, axs = pplt.subplots(ncols=2, nrows=2, axwidth=2) + fig, axs = uplt.subplots(ncols=2, nrows=2, axwidth=2) hs = axs[0].plot(state.rand(10, 6)) locs = ["l", "t", "r", "uc", "ul", "ll"] locs = ["l", "t", "uc", "ll"] @@ -52,7 +52,7 @@ def test_centered_legends(): ax.legend(hs, loc=loc, ncol=3, labels=labels, center=True) # Pass centered legends with keywords or list-of-list input. - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() hs = ax.plot(state.rand(10, 5), labels=list("abcde")) ax.legend(hs, center=True, loc="b") ax.legend(hs + hs[:1], loc="r", ncol=1) @@ -68,12 +68,12 @@ def test_manual_labels(): order objects were drawn in then assigning labels to them. Similar to using OO interface and rejecting pyplot "current axes" and "current figure". """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() (h1,) = ax.plot([0, 1, 2], label="label1") (h2,) = ax.plot([0, 1, 1], label="label2") for loc in ("best", "bottom"): ax.legend([h1, h2], loc=loc, labels=[None, "override"]) - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.plot([0, 1, 2]) ax.plot([0, 1, 1]) for loc in ("best", "bottom"): @@ -90,7 +90,7 @@ def test_contour_legend_with_label(): figs = [] label = "label" - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) ax = axs[0] ax.contour(state.rand(5, 5), color="k", label=label, legend="b") ax = axs[1] @@ -106,7 +106,7 @@ def test_contour_legend_without_label(): figs = [] label = None - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) ax = axs[0] ax.contour(state.rand(5, 5), color="k", label=label, legend="b") ax = axs[1] @@ -119,8 +119,8 @@ def test_histogram_legend(): """ Support complex histogram legends. """ - pplt.rc.inlinefmt = "svg" - fig, ax = pplt.subplots() + uplt.rc.inlinefmt = "svg" + fig, ax = uplt.subplots() res = ax.hist( state.rand(500, 2), 4, labels=("label", "other"), edgefix=True, legend="b" ) @@ -129,7 +129,7 @@ def test_histogram_legend(): {"length": [1.5, 0.5, 1.2, 0.9, 3], "width": [0.7, 0.2, 0.15, 0.2, 1.1]}, index=["pig", "rabbit", "duck", "chicken", "horse"], ) - fig, axs = pplt.subplots(ncols=3) + fig, axs = uplt.subplots(ncols=3) ax = axs[0] res = ax.hist(df, bins=3, legend=True, lw=3) ax.legend(loc="b") @@ -144,12 +144,12 @@ def test_multiple_calls(): """ Test successive plotting additions to guides. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() ax.pcolor(state.rand(10, 10), colorbar="b") ax.pcolor(state.rand(10, 5), cmap="grays", colorbar="b") ax.pcolor(state.rand(10, 5), cmap="grays", colorbar="b") - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() data = state.rand(10, 5) for i in range(data.shape[1]): ax.plot(data[:, i], colorbar="b", label=f"x{i}", colorbar_kw={"label": "hello"}) @@ -163,7 +163,7 @@ def test_tuple_handles(): """ from matplotlib import legend_handler - fig, ax = pplt.subplots(refwidth=3, abc="A.", abcloc="ul", span=False) + fig, ax = uplt.subplots(refwidth=3, abc="A.", abcloc="ul", span=False) patches = ax.fill_between(state.rand(10, 3), stack=True) lines = ax.line(1 + 0.5 * (state.rand(10, 3) - 0.5).cumsum(axis=0)) # ax.legend([(handles[0], lines[1])], ['joint label'], loc='bottom', queue=True) diff --git a/ultraplot/tests/test_projections.py b/ultraplot/tests/test_projections.py index 585ba98a5..b485218c8 100644 --- a/ultraplot/tests/test_projections.py +++ b/ultraplot/tests/test_projections.py @@ -5,7 +5,7 @@ import cartopy.crs as ccrs import matplotlib.pyplot as plt import numpy as np -import ultraplot as pplt +import ultraplot as uplt import pytest state = np.random.RandomState(51423) @@ -16,21 +16,21 @@ def test_aspect_ratios(): """ Test aspect ratio adjustments. """ - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) axs[0].format(aspect=1.5) - fig, axs = pplt.subplots(ncols=2, proj=("cart", "cyl"), aspect=2) + fig, axs = uplt.subplots(ncols=2, proj=("cart", "cyl"), aspect=2) axs[0].set_aspect(1) return fig -if pplt.internals._version_mpl <= "3.2": +if uplt.internals._version_mpl <= "3.2": @pytest.mark.mpl_image_compare def test_basemap_labels(): """ Add basemap labels. """ - fig, axs = pplt.subplots(ncols=2, proj="robin", refwidth=3, basemap=True) + fig, axs = uplt.subplots(ncols=2, proj="robin", refwidth=3, basemap=True) axs.format(coast=True, labels="rt") return fig @@ -40,7 +40,7 @@ def test_cartopy_labels(): """ Add cartopy labels. """ - fig, axs = pplt.subplots(ncols=2, proj="robin", refwidth=3) + fig, axs = uplt.subplots(ncols=2, proj="robin", refwidth=3) axs.format(coast=True, labels=True) axs[0].format(inlinelabels=True) axs[1].format(rotatelabels=True) @@ -70,8 +70,8 @@ def test_cartopy_contours(): vmax=5, ) fig.colorbar(m, ax=ax) - fig = pplt.figure() - ax = fig.add_subplot(projection=pplt.Mollweide(), extent="auto") + fig = uplt.figure() + ax = fig.add_subplot(projection=uplt.Mollweide(), extent="auto") ax.coastlines() N = 10 m = ax.contourf( @@ -79,7 +79,7 @@ def test_cartopy_contours(): np.linspace(0, 90, N)[1::2], state.rand(N // 2, N) * 10 + 5, cmap="BuRd", - transform=pplt.PlateCarree(), + transform=uplt.PlateCarree(), edgefix=False, ) fig.colorbar(m, ax=ax) @@ -91,8 +91,8 @@ def test_cartopy_manual(): """ Test alternative workflow without classes. """ - fig = pplt.figure() - proj = pplt.Proj("npstere") + fig = uplt.figure() + proj = uplt.Proj("npstere") # fig.add_axes([0.1, 0.1, 0.9, 0.9], proj='geo', map_projection=proj) fig.add_subplot(111, proj="geo", land=True, map_projection=proj) return fig @@ -103,8 +103,8 @@ def test_three_axes(): """ Test basic 3D axes here. """ - pplt.rc["tick.minor"] = False - fig, ax = pplt.subplots(proj="3d", outerpad=3) + uplt.rc["tick.minor"] = False + fig, ax = uplt.subplots(proj="3d", outerpad=3) return fig @@ -113,7 +113,7 @@ def test_projection_dicts(): """ Test projection dictionaries. """ - fig = pplt.figure(refnum=1) + fig = uplt.figure(refnum=1) a = [[1, 0], [1, 4], [2, 4], [2, 4], [3, 4], [3, 0]] fig.subplots(a, proj={1: "cyl", 2: "cart", 3: "cart", 4: "cart"}) return fig @@ -124,7 +124,7 @@ def test_polar_projections(): """ Rigorously test polar features here. """ - fig, ax = pplt.subplots(proj="polar") + fig, ax = uplt.subplots(proj="polar") ax.format( rlabelpos=45, thetadir=-1, diff --git a/ultraplot/tests/test_statistical_plotting.py b/ultraplot/tests/test_statistical_plotting.py index 7c16e6413..a4bd94f75 100644 --- a/ultraplot/tests/test_statistical_plotting.py +++ b/ultraplot/tests/test_statistical_plotting.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# import ultraplot as pplt -import numpy as np, pandas as pd, ultraplot as pplt +# import ultraplot as uplt +import numpy as np, pandas as pd, ultraplot as uplt import pytest @@ -15,7 +15,7 @@ def test_statistical_boxplot(): data2 = pd.DataFrame(data2, columns=pd.Index(list("abcdefg"), name="label")) # Figure - fig, axs = pplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], span=False) + fig, axs = uplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], span=False) axs.format(abc="A.", titleloc="l", grid=False, suptitle="Boxes and violins demo") # Box plots @@ -42,10 +42,10 @@ def test_panel_dist(): state = np.random.RandomState(51423) x = state.normal(size=(N,)) y = state.normal(size=(N,)) - bins = pplt.arange(-3, 3, 0.25) + bins = uplt.arange(-3, 3, 0.25) # Histogram with marginal distributions - fig, axs = pplt.subplots(ncols=2, refwidth=2.3) + fig, axs = uplt.subplots(ncols=2, refwidth=2.3) axs.format( abc="A.", abcloc="l", @@ -67,7 +67,7 @@ def test_panel_dist(): colorbar="b", colorbar_kw={"label": "count"}, ) - color = pplt.scale_luminance(color, 1.5) # histogram colors + color = uplt.scale_luminance(color, 1.5) # histogram colors px = ax.panel(which, space=0) px.histh(y, bins, color=color, fill=True, ec="k") px.format(grid=False, xlocator=[], xreverse=(which == "l")) diff --git a/ultraplot/tests/test_subplots.py b/ultraplot/tests/test_subplots.py index d4d50a909..487920ce8 100644 --- a/ultraplot/tests/test_subplots.py +++ b/ultraplot/tests/test_subplots.py @@ -2,7 +2,7 @@ """ Test subplot layout. """ -import numpy as np, ultraplot as pplt, pytest +import numpy as np, ultraplot as uplt, pytest @pytest.mark.mpl_image_compare @@ -10,7 +10,7 @@ def test_align_labels(): """ Test spanning and aligned labels. """ - fig, axs = pplt.subplots( + fig, axs = uplt.subplots( [[2, 1, 4], [2, 3, 5]], refnum=2, refwidth=1.5, align=1, span=0 ) fig.format(xlabel="xlabel", ylabel="ylabel", abc="A.", abcloc="ul") @@ -26,10 +26,10 @@ def test_share_all_basic(): """ # Simple example N = 10 - fig, axs = pplt.subplots(nrows=1, ncols=2, refwidth=1.5, share="all") + fig, axs = uplt.subplots(nrows=1, ncols=2, refwidth=1.5, share="all") axs[0].plot(np.arange(N) * 1e2, np.arange(N) * 1e4) # Complex example - fig, axs = pplt.subplots(nrows=2, ncols=2, refwidth=1.5, share="all") + fig, axs = uplt.subplots(nrows=2, ncols=2, refwidth=1.5, share="all") axs[0].panel("b") pax = axs[0].panel("r") pax.format(ylabel="label") @@ -42,7 +42,7 @@ def test_span_labels(): """ Rigorous tests of spanning and aligned labels feature. """ - fig, axs = pplt.subplots([[1, 2, 4], [1, 3, 5]], refwidth=1.5, share=0, span=1) + fig, axs = uplt.subplots([[1, 2, 4], [1, 3, 5]], refwidth=1.5, share=0, span=1) fig.format(xlabel="xlabel", ylabel="ylabel", abc="A.", abcloc="ul") axs[1].format() # xlabel='xlabel') axs[2].format() @@ -54,7 +54,7 @@ def test_title_deflection(): """ Test the deflection of titles above and below panels. """ - fig, ax = pplt.subplots() + fig, ax = uplt.subplots() # ax.format(abc='A.', title='Title', titleloc='left', titlepad=30) tax = ax.panel_axes("top") ax.format(titleabove=False) # redirects to bottom @@ -71,7 +71,7 @@ def test_complex_ticks(): Normally title offset with these different tick arrangements is tricky but `_update_title_position` accounts for edge cases. """ - fig, axs = pplt.subplots(ncols=2) + fig, axs = uplt.subplots(ncols=2) axs[0].format( xtickloc="both", xticklabelloc="top", @@ -96,13 +96,13 @@ def test_both_ticklabels(): """ Test both tick labels. """ - fig, ax = pplt.subplots() # when both, have weird bug + fig, ax = uplt.subplots() # when both, have weird bug ax.format(xticklabelloc="both", title="title", suptitle="Test") - fig, ax = pplt.subplots() # when *just top*, bug disappears + fig, ax = uplt.subplots() # when *just top*, bug disappears ax.format(xtickloc="top", xticklabelloc="top", title="title", suptitle="Test") - fig, ax = pplt.subplots() # not sure here + fig, ax = uplt.subplots() # not sure here ax.format(xtickloc="both", xticklabelloc="neither", suptitle="Test") - fig, ax = pplt.subplots() # doesn't seem to change the title offset though + fig, ax = uplt.subplots() # doesn't seem to change the title offset though ax.format(xtickloc="top", xticklabelloc="neither", suptitle="Test") return fig @@ -111,12 +111,12 @@ def test_gridspec_copies(): """ Test whether gridspec copies work. """ - fig1, ax = pplt.subplots(ncols=2) + fig1, ax = uplt.subplots(ncols=2) gs = fig1.gridspec.copy(left=5, wspace=0, right=5) return fig1 - fig2 = pplt.figure() + fig2 = uplt.figure() fig2.add_subplots(gs) - fig = pplt.figure() + fig = uplt.figure() with pytest.raises(ValueError): fig.add_subplots(gs) # should raise error @@ -126,7 +126,7 @@ def test_aligned_outer_guides(): """ Test alignment adjustment. """ - fig, ax = pplt.subplot() + fig, ax = uplt.subplot() h1 = ax.plot(np.arange(5), label="foo") h2 = ax.plot(np.arange(5) + 1, label="bar") h3 = ax.plot(np.arange(5) + 2, label="baz") @@ -148,14 +148,14 @@ def test_reference_aspect(): """ # A simple test refwidth = 1.5 - fig, axs = pplt.subplots(ncols=2, refwidth=refwidth) + fig, axs = uplt.subplots(ncols=2, refwidth=refwidth) fig.auto_layout() assert np.isclose(refwidth, axs[fig._refnum - 1]._get_size_inches()[0]) # A test with funky layout refwidth = 1.5 - fig, axs = pplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], ref=3, refwidth=refwidth) + fig, axs = uplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], ref=3, refwidth=refwidth) axs[1].panel_axes("left") axs.format(xlocator=0.2, ylocator=0.2) fig.auto_layout() @@ -163,7 +163,7 @@ def test_reference_aspect(): # A test with panels refwidth = 2.0 - fig, axs = pplt.subplots( + fig, axs = uplt.subplots( [[1, 1, 2], [3, 4, 5], [3, 4, 6]], hratios=(2, 1, 1), refwidth=refwidth ) axs[2].panel_axes("right", width=0.5) diff --git a/ultraplot/ticker.py b/ultraplot/ticker.py index 8e1f1a201..670f532ef 100644 --- a/ultraplot/ticker.py +++ b/ultraplot/ticker.py @@ -444,7 +444,7 @@ def _fix_small_number(self, x, string, precision_offset=2): # only meant to be used for linear scales and cannot handle the wide # range of magnitudes in e.g. log scales. To correct this, we only # truncate if value is within `offset` order of magnitude of the float - # precision. Common issue is e.g. levels=pplt.arange(-1, 1, 0.1). + # precision. Common issue is e.g. levels=uplt.arange(-1, 1, 0.1). # This choice satisfies even 1000 additions of 0.1 to -100. m = REGEX_ZERO.match(string) decimal_point = self._get_decimal_point() diff --git a/ultraplot/utils.py b/ultraplot/utils.py index 4a36fa595..5e3a7b0fb 100644 --- a/ultraplot/utils.py +++ b/ultraplot/utils.py @@ -118,10 +118,10 @@ def _with_stripped_units(data, *args, **kwargs): def arange(min_, *args): """ Identical to `numpy.arange` but with inclusive endpoints. For example, - ``pplt.arange(2, 4)`` returns the numpy array ``[2, 3, 4]`` instead of + ``uplt.arange(2, 4)`` returns the numpy array ``[2, 3, 4]`` instead of ``[2, 3]``. This is useful for generating lists of tick locations or - colormap levels, e.g. ``ax.format(xlocator=pplt.arange(0, 10))`` - or ``ax.pcolor(levels=pplt.arange(0, 10))``. + colormap levels, e.g. ``ax.format(xlocator=uplt.arange(0, 10))`` + or ``ax.pcolor(levels=uplt.arange(0, 10))``. Parameters ----------