|
62 | 62 | state = np.random.RandomState(51423) |
63 | 63 | x = np.linspace(0, 2 * np.pi, N)[:, None] + np.arange(5) * 2 * np.pi / 5 |
64 | 64 | y = 100 * (state.rand(N, 5) - 0.3).cumsum(axis=0) / N |
65 | | -fig, axs = uplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], proj="polar") |
| 65 | +fig, axs = uplt.subplots([[1, 1, 2, 2], [0, 3, 3, 0]], proj="polar", share=0) |
66 | 66 | axs.format( |
67 | 67 | suptitle="Polar axes demo", |
68 | 68 | linewidth=1, |
|
134 | 134 | # Use an on-the-fly projection |
135 | 135 | import ultraplot as uplt |
136 | 136 |
|
137 | | -fig = uplt.figure(refwidth=3) |
138 | | -axs = fig.subplots(nrows=2, proj="robin", proj_kw={"lon0": 150}) |
139 | | -# proj = uplt.Proj('robin', lon0=180) |
140 | | -# axs = uplt.subplots(nrows=2, proj=proj) # equivalent to above |
| 137 | +fig = uplt.figure(refwidth=3, share=0) |
| 138 | +axs = fig.subplots( |
| 139 | + nrows=2, |
| 140 | + proj="robin", |
| 141 | + proj_kw={"lon0": 150}, |
| 142 | +) |
141 | 143 | axs.format( |
142 | 144 | suptitle="Figure with single projection", |
143 | 145 | land=True, |
|
151 | 153 | # Geographic backends |
152 | 154 | # ------------------- |
153 | 155 | # |
154 | | -# The :class:`ultraplot.axes.GeoAxes` class uses either `cartopy`_ or `basemap`_ as "backends" |
| 156 | +# The :class:`~ultraplot.axes.GeoAxes` class uses either `cartopy`_ or `basemap`_ as "backends" |
155 | 157 | # to :ref:`format the axes <ug_geoformat>` and :ref:`plot stuff <ug_geoplot>` in |
156 | 158 | # the axes. A few details: |
157 | 159 | # |
|
224 | 226 | # %% |
225 | 227 | import ultraplot as uplt |
226 | 228 |
|
227 | | -fig = uplt.figure() |
| 229 | +fig = uplt.figure(share=0) |
228 | 230 |
|
229 | 231 | # Add projections |
230 | 232 | gs = uplt.GridSpec(ncols=2, nrows=3, hratios=(1, 1, 1.4)) |
|
254 | 256 | # Plotting in projections |
255 | 257 | # ----------------------- |
256 | 258 | # |
257 | | -# In UltraPlot, plotting with `~ultraplot.axes.GeoAxes` is just like plotting |
| 259 | +# In UltraPlot, plotting with :class:`~ultraplot.axes.GeoAxes` is just like plotting |
258 | 260 | # with :class:`~ultraplot.axes.CartesianAxes`. UltraPlot makes longitude-latitude |
259 | 261 | # (i.e., Plate Carrée) coordinates the *default* coordinate system for all plotting |
260 | 262 | # commands by internally passing ``transform=ccrs.PlateCarree()`` to cartopy commands |
|
291 | 293 | for globe in (False, True): |
292 | 294 | string = "with" if globe else "without" |
293 | 295 | gs = uplt.GridSpec(nrows=2, ncols=2) |
294 | | - fig = uplt.figure(refwidth=2.5) |
| 296 | + fig = uplt.figure(refwidth=2.5, share=0) |
295 | 297 | for i, ss in enumerate(gs): |
296 | 298 | cmap = ("sunset", "sunrise")[i % 2] |
297 | 299 | backend = ("cartopy", "basemap")[i % 2] |
|
321 | 323 | # Formatting projections |
322 | 324 | # ---------------------- |
323 | 325 | # |
324 | | -# The :meth:`ultraplot.axes.GeoAxes.format` command facilitates geographic-specific axes |
| 326 | +# The :meth:`~ultraplot.axes.GeoAxes.format` command facilitates geographic-specific axes |
325 | 327 | # modifications. It can toggle and configure the "major" and "minor" longitude and |
326 | 328 | # latitude gridline locations using the `grid`, `lonlocator`, `latlocator`, `gridminor`, |
327 | 329 | # `lonminorlocator`, and `latminorlocator` keys, and configure gridline label formatting |
|
334 | 336 | # to ``True``. The padding between the map edge and the labels can be changed |
335 | 337 | # using `labelpad` or by changing :rcraw:`grid.labelpad`. |
336 | 338 | # |
337 | | -# `ultraplot.axes.GeoAxes.format` can also set the cartopy projection bounding longitudes |
| 339 | +# :meth:`~ultraplot.axes.GeoAxes.format` can also set the cartopy projection bounding longitudes |
338 | 340 | # and latitudes with `lonlim` and `latlim` (analogous to `xlim` and `ylim`), set the |
339 | 341 | # latitude bound for circular polar projections using `boundinglat`, and toggle and |
340 | 342 | # configure geographic features like land masses, coastlines, and administrative |
|
349 | 351 | import ultraplot as uplt |
350 | 352 |
|
351 | 353 | gs = uplt.GridSpec(ncols=3, nrows=2, wratios=(1, 1, 1.2), hratios=(1, 1.2)) |
352 | | -fig = uplt.figure(refwidth=4) |
| 354 | +fig = uplt.figure(refwidth=4, share=0) |
353 | 355 |
|
354 | 356 | # Styling projections in different ways |
355 | 357 | ax = fig.subplot(gs[0, :2], proj="eqearth") |
|
444 | 446 | # Plate Carrée map projection |
445 | 447 | uplt.rc.reso = "med" # use higher res for zoomed in geographic features |
446 | 448 | basemap = uplt.Proj("cyl", lonlim=(-20, 180), latlim=(-10, 50), backend="basemap") |
447 | | -fig, axs = uplt.subplots(nrows=2, refwidth=5, proj=("cyl", basemap)) |
| 449 | +fig, axs = uplt.subplots(nrows=2, refwidth=5, proj=("cyl", basemap), share=0) |
448 | 450 | axs.format( |
449 | 451 | land=True, |
450 | 452 | labels=True, |
|
462 | 464 |
|
463 | 465 | # Pole-centered map projections |
464 | 466 | basemap = uplt.Proj("npaeqd", boundinglat=60, backend="basemap") |
465 | | -fig, axs = uplt.subplots(ncols=2, refwidth=2.7, proj=("splaea", basemap)) |
| 467 | +fig, axs = uplt.subplots(ncols=2, refwidth=2.7, proj=("splaea", basemap), share=0) |
466 | 468 | fig.format(suptitle="Zooming into polar projections") |
467 | 469 | axs.format(land=True, latmax=80) # no gridlines poleward of 80 degrees |
468 | 470 | axs[0].format(boundinglat=-60, title="Cartopy example") |
|
472 | 474 | import ultraplot as uplt |
473 | 475 |
|
474 | 476 | # Zooming in on continents |
475 | | -fig = uplt.figure(refwidth=3) |
| 477 | +fig = uplt.figure(refwidth=3, share=0) |
476 | 478 | ax = fig.subplot(121, proj="lcc", proj_kw={"lon0": 0}) |
477 | 479 | ax.format(lonlim=(-20, 50), latlim=(30, 70), title="Cartopy example") |
478 | 480 | proj = uplt.Proj("lcc", lon0=-100, lat0=45, width=8e6, height=8e6, backend="basemap") |
|
557 | 559 | "eck5", |
558 | 560 | "eck6", |
559 | 561 | ] |
560 | | -fig, axs = uplt.subplots(ncols=3, nrows=10, figwidth=7, proj=projs) |
| 562 | +fig, axs = uplt.subplots(ncols=3, nrows=10, figwidth=7, proj=projs, share=0) |
561 | 563 | axs.format(land=True, reso="lo", labels=False, suptitle="Table of cartopy projections") |
562 | 564 | for proj, ax in zip(projs, axs): |
563 | 565 | ax.format(title=proj, titleweight="bold", labels=False) |
|
592 | 594 | "npaeqd", |
593 | 595 | "nplaea", |
594 | 596 | ] |
595 | | -fig, axs = uplt.subplots(ncols=3, nrows=8, figwidth=7, proj=projs, backend="basemap") |
| 597 | +fig, axs = uplt.subplots( |
| 598 | + ncols=3, nrows=8, figwidth=7, proj=projs, backend="basemap", share=0 |
| 599 | +) |
596 | 600 | axs.format(land=True, labels=False, suptitle="Table of basemap projections") |
597 | 601 | for proj, ax in zip(projs, axs): |
598 | 602 | ax.format(title=proj, titleweight="bold", labels=False) |
0 commit comments