|
423 | 423 | # %% |
424 | 424 | import proplot as pplt |
425 | 425 | import numpy as np |
| 426 | + |
| 427 | +# Create figure |
426 | 428 | pplt.rc.reset() |
| 429 | +state = np.random.RandomState(51423) |
| 430 | +colors = ('coral', 'sky blue') |
427 | 431 | fig, axs = pplt.subplots(nrows=2, ncols=3, refwidth=1.7, share=0, order='F') |
428 | 432 | axs.format( |
429 | | - toplabels=('Power scales', 'Exponential scales', 'Cartographic scales'), |
| 433 | + toplabels=('Geographic scales', 'Exponential scales', 'Power scales'), |
430 | 434 | ) |
431 | | -x = np.linspace(0, 1, 50) |
432 | | -y = 10 * x |
433 | | -state = np.random.RandomState(51423) |
434 | | -data = state.rand(len(y) - 1, len(x) - 1) |
435 | 435 |
|
436 | | -# Power scales |
437 | | -colors = ('coral', 'sky blue') |
438 | | -for ax, power, color in zip(axs[:2], (2, 1 / 4), colors): |
439 | | - ax.pcolormesh(x, y, data, cmap='grays', cmap_kw={'right': 0.8}) |
440 | | - ax.plot(x, y, lw=4, color=color) |
| 436 | +# Geographic scales |
| 437 | +n = 20 |
| 438 | +x = np.linspace(-180, 180, n) |
| 439 | +y1 = np.linspace(-85, 85, n) |
| 440 | +y2 = np.linspace(-85, 85, n) |
| 441 | +data = state.rand(len(x) - 1, len(y2) - 1) |
| 442 | +for ax, scale, color in zip(axs[:2], ('sine', 'mercator'), colors): |
| 443 | + ax.plot(x, y1, '-', color=color, lw=4) |
| 444 | + ax.pcolormesh(x, y2, data, cmap='grays', cmap_kw={'right': 0.8}) |
441 | 445 | ax.format( |
442 | | - ylim=(0.1, 10), yscale=('power', power), |
443 | | - title=f'$x^{{{power}}}$' |
| 446 | + title=scale.title() + ' y-axis', yscale=scale, ytickloc='left', |
| 447 | + yformatter='deg', grid=False, ylocator=20, |
| 448 | + xscale='linear', xlim=None, ylim=(-85, 85) |
444 | 449 | ) |
445 | 450 |
|
446 | 451 | # Exp scales |
| 452 | +x = np.linspace(0, 1, 50) |
| 453 | +y = 10 * x |
| 454 | +data = state.rand(len(y) - 1, len(x) - 1) |
447 | 455 | for ax, a, c, color in zip(axs[2:4], (np.e, 2), (0.5, 2), colors): |
448 | 456 | ax.pcolormesh(x, y, data, cmap='grays', cmap_kw={'right': 0.8}) |
449 | 457 | ax.plot(x, y, lw=4, color=color) |
|
452 | 460 | title=f"${(a, 'e')[a == np.e]}^{{{(c, '')[c == 1]}x}}$" |
453 | 461 | ) |
454 | 462 |
|
455 | | -# Geographic scales |
456 | | -n = 20 |
457 | | -x = np.linspace(-180, 180, n) |
458 | | -y1 = np.linspace(-85, 85, n) |
459 | | -y2 = np.linspace(-85, 85, n) |
460 | | -data = state.rand(len(x) - 1, len(y2) - 1) |
461 | | -for ax, scale, color in zip(axs[4:], ('sine', 'mercator'), ('coral', 'sky blue')): |
462 | | - ax.plot(x, y1, '-', color=color, lw=4) |
463 | | - ax.pcolormesh(x, y2, data, cmap='grays', cmap_kw={'right': 0.8}) |
| 463 | +# Power scales |
| 464 | +for ax, power, color in zip(axs[4:], (2, 1 / 4), colors): |
| 465 | + ax.pcolormesh(x, y, data, cmap='grays', cmap_kw={'right': 0.8}) |
| 466 | + ax.plot(x, y, lw=4, color=color) |
464 | 467 | ax.format( |
465 | | - title=scale.title() + ' y-axis', yscale=scale, ytickloc='left', |
466 | | - yformatter='deg', grid=False, ylocator=20, |
467 | | - xscale='linear', xlim=None, ylim=(-85, 85) |
| 468 | + ylim=(0.1, 10), yscale=('power', power), |
| 469 | + title=f'$x^{{{power}}}$' |
468 | 470 | ) |
469 | 471 |
|
470 | 472 |
|
|
0 commit comments