|
63 | 63 | # the :rcraw:`cmap.inbounds` setting and the :ref:`user guide <ug_2dstd>`). |
64 | 64 |
|
65 | 65 | # %% |
66 | | -import ultraplot as pplt |
| 66 | +import ultraplot as uplt |
67 | 67 | import numpy as np |
68 | 68 |
|
69 | 69 | N = 5 |
70 | 70 | state = np.random.RandomState(51423) |
71 | | -with pplt.rc.context({"axes.prop_cycle": pplt.Cycle("Grays", N=N, left=0.3)}): |
| 71 | +with uplt.rc.context({"axes.prop_cycle": uplt.Cycle("Grays", N=N, left=0.3)}): |
72 | 72 | # Sample data |
73 | 73 | x = np.linspace(-5, 5, N) |
74 | 74 | y = state.rand(N, 5) |
75 | | - fig = pplt.figure(share=False, suptitle="Standardized input demonstration") |
| 75 | + fig = uplt.figure(share=False, suptitle="Standardized input demonstration") |
76 | 76 |
|
77 | 77 | # Plot by passing both x and y coordinates |
78 | 78 | ax = fig.subplot(121, title="Manual x coordinates") |
|
92 | 92 | fig.format(xlabel="xlabel", ylabel="ylabel") |
93 | 93 |
|
94 | 94 | # %% |
95 | | -import ultraplot as pplt |
| 95 | +import ultraplot as uplt |
96 | 96 | import numpy as np |
97 | 97 |
|
98 | 98 | # Sample data |
99 | | -cycle = pplt.Cycle("davos", right=0.8) |
| 99 | +cycle = uplt.Cycle("davos", right=0.8) |
100 | 100 | state = np.random.RandomState(51423) |
101 | 101 | N, M = 400, 20 |
102 | 102 | xmax = 20 |
103 | 103 | x = np.linspace(0, 100, N) |
104 | 104 | y = 100 * (state.rand(N, M) - 0.42).cumsum(axis=0) |
105 | 105 |
|
106 | 106 | # Plot the data |
107 | | -fig = pplt.figure(refwidth=2.2, share=False) |
| 107 | +fig = uplt.figure(refwidth=2.2, share=False) |
108 | 108 | axs = fig.subplots([[0, 1, 1, 0], [2, 2, 3, 3]], wratios=(2, 1, 1, 2)) |
109 | 109 | axs[0].axvspan( |
110 | 110 | 0, |
111 | 111 | xmax, |
112 | 112 | zorder=3, |
113 | 113 | edgecolor="red", |
114 | | - facecolor=pplt.set_alpha("red", 0.2), |
| 114 | + facecolor=uplt.set_alpha("red", 0.2), |
115 | 115 | ) |
116 | 116 | for i, ax in enumerate(axs): |
117 | 117 | inbounds = i == 1 |
|
191 | 191 | df.columns.name = "category" |
192 | 192 |
|
193 | 193 | # %% |
194 | | -import ultraplot as pplt |
| 194 | +import ultraplot as uplt |
195 | 195 |
|
196 | | -fig = pplt.figure(share=False, suptitle="Automatic subplot formatting") |
| 196 | +fig = uplt.figure(share=False, suptitle="Automatic subplot formatting") |
197 | 197 |
|
198 | 198 | # Plot DataArray |
199 | | -cycle = pplt.Cycle("dark blue", space="hpl", N=da.shape[1]) |
| 199 | +cycle = uplt.Cycle("dark blue", space="hpl", N=da.shape[1]) |
200 | 200 | ax = fig.subplot(121) |
201 | 201 | ax.scatter(da, cycle=cycle, lw=3, colorbar="t", colorbar_kw={"locator": 20}) |
202 | 202 |
|
203 | 203 | # Plot Dataframe |
204 | | -cycle = pplt.Cycle("dark green", space="hpl", N=df.shape[1]) |
| 204 | +cycle = uplt.Cycle("dark green", space="hpl", N=df.shape[1]) |
205 | 205 | ax = fig.subplot(122) |
206 | 206 | ax.plot(df, cycle=cycle, lw=3, legend="t", legend_kw={"frame": False}) |
207 | 207 |
|
|
230 | 230 | # <https://matplotlib.org/stable/tutorials/intermediate/color_cycle.html#sphx-glr-tutorials-intermediate-color-cycle-py>`__. |
231 | 231 |
|
232 | 232 | # %% |
233 | | -import ultraplot as pplt |
| 233 | +import ultraplot as uplt |
234 | 234 | import numpy as np |
235 | 235 |
|
236 | 236 | # Sample data |
|
241 | 241 | data1 += state.rand(M, N) |
242 | 242 | data2 += state.rand(M, N) |
243 | 243 |
|
244 | | -with pplt.rc.context({"lines.linewidth": 3}): |
| 244 | +with uplt.rc.context({"lines.linewidth": 3}): |
245 | 245 | # Use property cycle for columns of 2D input data |
246 | | - fig = pplt.figure(share=False) |
| 246 | + fig = uplt.figure(share=False) |
247 | 247 | ax = fig.subplot(121, title="Single plot call") |
248 | 248 | ax.plot( |
249 | 249 | 2 * data1 + data2, |
|
283 | 283 | # "positive" lines using ``negpos=True`` (see :ref:`below <ug_negpos>` for details). |
284 | 284 |
|
285 | 285 | # %% |
286 | | -import ultraplot as pplt |
| 286 | +import ultraplot as uplt |
287 | 287 | import numpy as np |
288 | 288 |
|
289 | 289 | state = np.random.RandomState(51423) |
290 | | -gs = pplt.GridSpec(nrows=3, ncols=2) |
291 | | -fig = pplt.figure(refwidth=2.2, span=False, share="labels") |
| 290 | +gs = uplt.GridSpec(nrows=3, ncols=2) |
| 291 | +fig = uplt.figure(refwidth=2.2, span=False, share="labels") |
292 | 292 |
|
293 | 293 | # Vertical vs. horizontal |
294 | 294 | data = (state.rand(10, 5) - 0.5).cumsum(axis=0) |
|
359 | 359 | # calls `~ultraplot.axes.Axes.scatter` internally. |
360 | 360 |
|
361 | 361 | # %% |
362 | | -import ultraplot as pplt |
| 362 | +import ultraplot as uplt |
363 | 363 | import numpy as np |
364 | 364 | import pandas as pd |
365 | 365 |
|
|
370 | 370 | data = pd.DataFrame(data, columns=pd.Index(["a", "b", "c", "d"], name="label")) |
371 | 371 |
|
372 | 372 | # Figure |
373 | | -gs = pplt.GridSpec(ncols=2, nrows=2) |
374 | | -fig = pplt.figure(refwidth=2.2, share="labels", span=False) |
| 373 | +gs = uplt.GridSpec(ncols=2, nrows=2) |
| 374 | +fig = uplt.figure(refwidth=2.2, share="labels", span=False) |
375 | 375 |
|
376 | 376 | # Vertical vs. horizontal |
377 | 377 | ax = fig.subplot(gs[0], title="Dependent x-axis") |
|
423 | 423 | # plot with a colorbar indicating the parametric coordinate. |
424 | 424 |
|
425 | 425 | # %% |
426 | | -import ultraplot as pplt |
| 426 | +import ultraplot as uplt |
427 | 427 | import numpy as np |
428 | 428 | import pandas as pd |
429 | 429 |
|
430 | | -gs = pplt.GridSpec(ncols=2, wratios=(2, 1)) |
431 | | -fig = pplt.figure(figwidth="16cm", refaspect=(2, 1), share=False) |
| 430 | +gs = uplt.GridSpec(ncols=2, wratios=(2, 1)) |
| 431 | +fig = uplt.figure(figwidth="16cm", refaspect=(2, 1), share=False) |
432 | 432 | fig.format(suptitle="Parametric plots demo") |
433 | 433 | cmap = "IceFire" |
434 | 434 |
|
|
518 | 518 | # `~ultraplot.axes.Axes.bar` or `~ultraplot.axes.Axes.barh` internally. |
519 | 519 |
|
520 | 520 | # %% |
521 | | -import ultraplot as pplt |
| 521 | +import ultraplot as uplt |
522 | 522 | import numpy as np |
523 | 523 | import pandas as pd |
524 | 524 |
|
|
532 | 532 | ) |
533 | 533 |
|
534 | 534 | # Figure |
535 | | -pplt.rc.abc = "a." |
536 | | -pplt.rc.titleloc = "l" |
537 | | -gs = pplt.GridSpec(nrows=2, hratios=(3, 2)) |
538 | | -fig = pplt.figure(refaspect=2, refwidth=4.8, share=False) |
| 535 | +uplt.rc.abc = "a." |
| 536 | +uplt.rc.titleloc = "l" |
| 537 | +gs = uplt.GridSpec(nrows=2, hratios=(3, 2)) |
| 538 | +fig = uplt.figure(refaspect=2, refwidth=4.8, share=False) |
539 | 539 |
|
540 | 540 | # Side-by-side bars |
541 | 541 | ax = fig.subplot(gs[0], title="Side-by-side") |
|
554 | 554 | stack=True, |
555 | 555 | ) |
556 | 556 | fig.format(grid=False, suptitle="Bar plot demo") |
557 | | -pplt.rc.reset() |
| 557 | +uplt.rc.reset() |
558 | 558 |
|
559 | 559 | # %% |
560 | | -import ultraplot as pplt |
| 560 | +import ultraplot as uplt |
561 | 561 | import numpy as np |
562 | 562 |
|
563 | 563 | # Sample data |
|
566 | 566 | cycle = ("gray3", "gray5", "gray7") |
567 | 567 |
|
568 | 568 | # Figure |
569 | | -pplt.rc.abc = "a." |
570 | | -pplt.rc.titleloc = "l" |
571 | | -fig = pplt.figure(refwidth=2.3, share=False) |
| 569 | +uplt.rc.abc = "a." |
| 570 | +uplt.rc.titleloc = "l" |
| 571 | +fig = uplt.figure(refwidth=2.3, share=False) |
572 | 572 |
|
573 | 573 | # Overlaid area patches |
574 | 574 | ax = fig.subplot(121, title="Fill between columns") |
|
594 | 594 | legend_kw={"center": True, "ncols": 2, "labels": ["z", "y", "qqqq"]}, |
595 | 595 | ) |
596 | 596 | fig.format(grid=False, xlabel="xlabel", ylabel="ylabel", suptitle="Area plot demo") |
597 | | -pplt.rc.reset() |
| 597 | +uplt.rc.reset() |
598 | 598 |
|
599 | 599 | # %% [raw] raw_mimetype="text/restructuredtext" |
600 | 600 | # .. _ug_negpos: |
|
613 | 613 | # ``negcolor=color`` and ``poscolor=color`` to the `~ultraplot.axes.PlotAxes` commands. |
614 | 614 |
|
615 | 615 | # %% |
616 | | -import ultraplot as pplt |
| 616 | +import ultraplot as uplt |
617 | 617 | import numpy as np |
618 | 618 |
|
619 | 619 | # Sample data |
620 | 620 | state = np.random.RandomState(51423) |
621 | 621 | data = 4 * (state.rand(40) - 0.5) |
622 | 622 |
|
623 | 623 | # Figure |
624 | | -pplt.rc.abc = "a." |
625 | | -pplt.rc.titleloc = "l" |
626 | | -fig, axs = pplt.subplots(nrows=3, refaspect=2, figwidth=5) |
| 624 | +uplt.rc.abc = "a." |
| 625 | +uplt.rc.titleloc = "l" |
| 626 | +fig, axs = uplt.subplots(nrows=3, refaspect=2, figwidth=5) |
627 | 627 | axs.format( |
628 | 628 | xmargin=0, |
629 | 629 | xlabel="xlabel", |
|
650 | 650 | ax.format(title="Area plot") |
651 | 651 |
|
652 | 652 | # Reset title styles changed above |
653 | | -pplt.rc.reset() |
| 653 | +uplt.rc.reset() |
0 commit comments