|
410 | 410 | # %%
|
411 | 411 | import proplot as plot
|
412 | 412 | import numpy as np
|
413 |
| -N = 50 |
414 |
| -cmap = 'IceFire' |
415 |
| -values = np.linspace(-N / 2, N / 2, N) |
416 | 413 | fig, axs = plot.subplots(
|
417 | 414 | share=0, ncols=2, wratios=(2, 1),
|
418 | 415 | axwidth='7cm', aspect=(2, 1)
|
419 | 416 | )
|
420 | 417 | axs.format(suptitle='Parametric plots demo')
|
| 418 | +cmap = 'IceFire' |
421 | 419 |
|
422 | 420 | # Parametric line with smooth gradations
|
423 | 421 | ax = axs[0]
|
424 | 422 | state = np.random.RandomState(51423)
|
| 423 | +N = 50 |
| 424 | +x = (state.rand(N) - 0.52).cumsum() |
| 425 | +y = state.rand(N) |
| 426 | +c = np.linspace(-N / 2, N / 2, N) # color values |
425 | 427 | m = ax.parametric(
|
426 |
| - (state.rand(N) - 0.5).cumsum(), state.rand(N), |
427 |
| - cmap=cmap, values=values, lw=7, extend='both' |
428 |
| -) |
429 |
| -ax.format( |
430 |
| - xlabel='xlabel', ylabel='ylabel', |
431 |
| - title='Line with smooth gradations' |
| 428 | + x, y, c, cmap=cmap, lw=7, interp=5, capstyle='round', joinstyle='round' |
432 | 429 | )
|
433 |
| -ax.format(xlim=(-1, 5), ylim=(-0.2, 1.2)) |
| 430 | +ax.format(xlabel='xlabel', ylabel='ylabel', title='Line with smooth gradations') |
| 431 | +ax.format(xmargin=0.05, ymargin=0.05) |
434 | 432 | ax.colorbar(m, loc='b', label='parametric coordinate', locator=5)
|
435 | 433 |
|
436 | 434 | # Parametric line with stepped gradations
|
437 | 435 | N = 12
|
438 | 436 | ax = axs[1]
|
439 |
| -values = np.linspace(-N / 2, N / 2, N + 1) |
440 | 437 | radii = np.linspace(1, 0.2, N + 1)
|
441 | 438 | angles = np.linspace(0, 4 * np.pi, N + 1)
|
442 | 439 | x = radii * np.cos(1.4 * angles)
|
443 | 440 | y = radii * np.sin(1.4 * angles)
|
444 |
| -m = ax.parametric(x, y, cmap=cmap, values=values, linewidth=15, interp=False) |
| 441 | +c = np.linspace(-N / 2, N / 2, N + 1) |
| 442 | +m = ax.parametric(x, y, c, cmap=cmap, lw=15) |
445 | 443 | ax.format(
|
446 | 444 | xlim=(-1, 1), ylim=(-1, 1), title='Step gradations',
|
447 | 445 | xlabel='cosine angle', ylabel='sine angle'
|
|
0 commit comments