|
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) |
| 75 | + fig = pplt.figure(share=False, suptitle='Standardized input demonstration') |
76 | 76 |
|
77 | 77 | # Plot by passing both x and y coordinates |
78 | | - ax = fig.subplot(121) |
| 78 | + ax = fig.subplot(121, title='Manual x coordinates') |
79 | 79 | ax.area(x, -1 * y / N, stack=True) |
80 | 80 | ax.bar(x, y, linewidth=0, alpha=1, width=0.8) |
81 | 81 | ax.plot(x, y + 1, linewidth=2) |
82 | 82 | ax.scatter(x, y + 2, marker='s', markersize=5**2) |
83 | | - ax.format(title='Manual x coordinates') |
84 | 83 |
|
85 | 84 | # Plot by passing just y coordinates |
86 | 85 | # Default x coordinates are inferred from DataFrame, |
87 | 86 | # inferred from DataArray, or set to np.arange(0, y.shape[0]) |
88 | | - ax = fig.subplot(122) |
| 87 | + ax = fig.subplot(122, title='Auto x coordinates') |
89 | 88 | ax.area(-1 * y / N, stack=True) |
90 | 89 | ax.bar(y, linewidth=0, alpha=1) |
91 | 90 | ax.plot(y + 1, linewidth=2) |
92 | 91 | ax.scatter(y + 2, marker='s', markersize=5**2) |
93 | | - ax.format(title='Auto x coordinates') |
94 | 92 | fig.format(xlabel='xlabel', ylabel='ylabel') |
95 | | - fig.format(suptitle='Standardized input demonstration') |
96 | 93 |
|
97 | 94 | # %% |
98 | 95 | import proplot as pplt |
|
199 | 196 |
|
200 | 197 | # %% |
201 | 198 | import proplot as pplt |
202 | | -fig = pplt.figure(share=False) |
203 | | -fig.format(suptitle='Automatic subplot formatting') |
| 199 | +fig = pplt.figure(share=False, suptitle='Automatic subplot formatting') |
204 | 200 |
|
205 | 201 | # Plot DataArray |
206 | 202 | cycle = pplt.Cycle('dark blue', space='hpl', N=da.shape[1]) |
|
251 | 247 | with pplt.rc.context({'lines.linewidth': 3}): |
252 | 248 | # Use property cycle for columns of 2D input data |
253 | 249 | fig = pplt.figure(share=False) |
254 | | - ax = fig.subplot(121) |
255 | | - ax.format(title='Single plot call') |
| 250 | + ax = fig.subplot(121, title='Single plot call') |
256 | 251 | ax.plot( |
257 | 252 | 2 * data1 + data2, |
258 | 253 | cycle='black', # cycle from monochromatic colormap |
259 | 254 | cycle_kw={'ls': ('-', '--', '-.', ':')} |
260 | 255 | ) |
261 | 256 |
|
262 | 257 | # Use property cycle with successive plot() calls |
263 | | - ax = fig.subplot(122) |
264 | | - ax.format(title='Multiple plot calls') |
| 258 | + ax = fig.subplot(122, title='Multiple plot calls') |
265 | 259 | for i in range(data1.shape[1]): |
266 | 260 | ax.plot(data1[:, i], cycle='Reds', cycle_kw={'N': N, 'left': 0.3}) |
267 | 261 | for i in range(data1.shape[1]): |
|
302 | 296 |
|
303 | 297 | # Vertical vs. horizontal |
304 | 298 | data = (state.rand(10, 5) - 0.5).cumsum(axis=0) |
305 | | -ax = fig.subplot(gs[0]) |
306 | | -ax.format(title='Dependent x-axis') |
| 299 | +ax = fig.subplot(gs[0], title='Dependent x-axis') |
307 | 300 | ax.line(data, lw=2.5, cycle='seaborn') |
308 | | -ax = fig.subplot(gs[1]) |
309 | | -ax.format(title='Dependent y-axis') |
| 301 | +ax = fig.subplot(gs[1], title='Dependent y-axis') |
310 | 302 | ax.linex(data, lw=2.5, cycle='seaborn') |
311 | 303 |
|
312 | 304 | # Vertical lines |
313 | 305 | gray = 'gray7' |
314 | 306 | data = state.rand(20) - 0.5 |
315 | | -ax = fig.subplot(gs[2]) |
| 307 | +ax = fig.subplot(gs[2], title='Vertical lines') |
316 | 308 | ax.area(data, color=gray, alpha=0.2) |
317 | 309 | ax.vlines(data, negpos=True, lw=2) |
318 | | -ax.format(title='Vertical lines') |
319 | 310 |
|
320 | 311 | # Horizontal lines |
321 | | -ax = fig.subplot(gs[3]) |
| 312 | +ax = fig.subplot(gs[3], title='Horizontal lines') |
322 | 313 | ax.areax(data, color=gray, alpha=0.2) |
323 | 314 | ax.hlines(data, negpos=True, lw=2) |
324 | | -ax.format(title='Horizontal lines') |
325 | 315 |
|
326 | 316 | # Step |
327 | | -ax = fig.subplot(gs[4]) |
| 317 | +ax = fig.subplot(gs[4], title='Step plot') |
328 | 318 | data = state.rand(20, 4).cumsum(axis=1).cumsum(axis=0) |
329 | 319 | cycle = ('gray6', 'blue7', 'red7', 'gray4') |
330 | 320 | ax.step(data, cycle=cycle, labels=list('ABCD'), legend='ul', legend_kw={'ncol': 2}) |
331 | | -ax.format(title='Step plot') |
332 | 321 |
|
333 | 322 | # Stems |
334 | | -ax = fig.subplot(gs[5]) |
| 323 | +ax = fig.subplot(gs[5], title='Stem plot') |
335 | 324 | data = state.rand(20) |
336 | 325 | ax.stem(data) |
337 | | -ax.format(title='Stem plot') |
338 | 326 | fig.format(suptitle='Line plots demo', xlabel='xlabel', ylabel='ylabel') |
339 | 327 |
|
340 | 328 |
|
|
390 | 378 | fig = pplt.figure(refwidth=2.2, share='labels', span=False) |
391 | 379 |
|
392 | 380 | # Vertical vs. horizontal |
393 | | -ax = fig.subplot(gs[0]) |
394 | | -ax.format(title='Dependent x-axis') |
| 381 | +ax = fig.subplot(gs[0], title='Dependent x-axis') |
395 | 382 | ax.scatter(data, cycle='538') |
396 | | -ax = fig.subplot(gs[1]) |
397 | | -ax.format(title='Dependent y-axis') |
| 383 | +ax = fig.subplot(gs[1], title='Dependent y-axis') |
398 | 384 | ax.scatterx(data, cycle='538') |
399 | 385 |
|
400 | 386 | # Scatter plot with property cycler |
401 | | -ax = fig.subplot(gs[2]) |
402 | | -ax.format(title='With property cycle') |
| 387 | +ax = fig.subplot(gs[2], title='With property cycle') |
403 | 388 | obj = ax.scatter( |
404 | 389 | x, data, legend='ul', legend_kw={'ncols': 2}, |
405 | 390 | cycle='Set2', cycle_kw={'m': ['x', 'o', 'x', 'o'], 'ms': [5, 10, 20, 30]} |
406 | 391 | ) |
407 | 392 |
|
408 | 393 | # Scatter plot with colormap |
409 | | -ax = fig.subplot(gs[3]) |
410 | | -ax.format(title='With colormap') |
| 394 | +ax = fig.subplot(gs[3], title='With colormap') |
411 | 395 | data = state.rand(2, 100) |
412 | 396 | obj = ax.scatter( |
413 | 397 | *data, |
|
532 | 516 | fig = pplt.figure(refaspect=2, refwidth=4.8, share=False) |
533 | 517 |
|
534 | 518 | # Side-by-side bars |
535 | | -ax = fig.subplot(gs[0]) |
| 519 | +ax = fig.subplot(gs[0], title='Side-by-side') |
536 | 520 | obj = ax.bar( |
537 | 521 | data, cycle='Reds', edgecolor='red9', colorbar='ul', colorbar_kw={'frameon': False} |
538 | 522 | ) |
539 | | -ax.format(xlocator=1, xminorlocator=0.5, ytickminor=False, title='Side-by-side') |
| 523 | +ax.format(xlocator=1, xminorlocator=0.5, ytickminor=False) |
540 | 524 |
|
541 | 525 | # Stacked bars |
542 | | -ax = fig.subplot(gs[1]) |
| 526 | +ax = fig.subplot(gs[1], title='Stacked') |
543 | 527 | obj = ax.barh( |
544 | 528 | data.iloc[::-1, :], cycle='Blues', edgecolor='blue9', legend='ur', stack=True, |
545 | 529 | ) |
546 | | -ax.format(title='Stacked') |
547 | 530 | fig.format(grid=False, suptitle='Bar plot demo') |
548 | 531 | pplt.rc.reset() |
549 | 532 |
|
|
562 | 545 | fig = pplt.figure(refwidth=2.3, share=False) |
563 | 546 |
|
564 | 547 | # Overlaid area patches |
565 | | -ax = fig.subplot(121) |
| 548 | +ax = fig.subplot(121, title='Fill between columns') |
566 | 549 | ax.area( |
567 | 550 | np.arange(5), data, data + state.rand(5)[:, None], cycle=cycle, alpha=0.7, |
568 | 551 | legend='uc', legend_kw={'center': True, 'ncols': 2, 'labels': ['z', 'y', 'qqqq']}, |
569 | 552 | ) |
570 | | -ax.format(title='Fill between columns') |
571 | 553 |
|
572 | 554 | # Stacked area patches |
573 | | -ax = fig.subplot(122) |
| 555 | +ax = fig.subplot(122, title='Stack between columns') |
574 | 556 | ax.area( |
575 | 557 | np.arange(5), data, stack=True, cycle=cycle, alpha=0.8, |
576 | 558 | legend='ul', legend_kw={'center': True, 'ncols': 2, 'labels': ['z', 'y', 'qqqq']}, |
577 | 559 | ) |
578 | | -ax.format(title='Stack between columns') |
579 | 560 | fig.format(grid=False, xlabel='xlabel', ylabel='ylabel', suptitle='Area plot demo') |
580 | 561 | pplt.rc.reset() |
581 | 562 |
|
|
0 commit comments