Skip to content

Commit fe85c84

Browse files
committed
Cleanup parametric examples
1 parent 7fbcc76 commit fe85c84

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

docs/1dplots.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -410,38 +410,36 @@
410410
# %%
411411
import proplot as plot
412412
import numpy as np
413-
N = 50
414-
cmap = 'IceFire'
415-
values = np.linspace(-N / 2, N / 2, N)
416413
fig, axs = plot.subplots(
417414
share=0, ncols=2, wratios=(2, 1),
418415
axwidth='7cm', aspect=(2, 1)
419416
)
420417
axs.format(suptitle='Parametric plots demo')
418+
cmap = 'IceFire'
421419

422420
# Parametric line with smooth gradations
423421
ax = axs[0]
424422
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
425427
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'
432429
)
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)
434432
ax.colorbar(m, loc='b', label='parametric coordinate', locator=5)
435433

436434
# Parametric line with stepped gradations
437435
N = 12
438436
ax = axs[1]
439-
values = np.linspace(-N / 2, N / 2, N + 1)
440437
radii = np.linspace(1, 0.2, N + 1)
441438
angles = np.linspace(0, 4 * np.pi, N + 1)
442439
x = radii * np.cos(1.4 * angles)
443440
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)
445443
ax.format(
446444
xlim=(-1, 1), ylim=(-1, 1), title='Step gradations',
447445
xlabel='cosine angle', ylabel='sine angle'

0 commit comments

Comments
 (0)