| 364 | return fig |
| 365 | |
| 366 | def PyplotGGPlotSytleSheet(): |
| 367 | import numpy as np |
| 368 | import matplotlib.pyplot as plt |
| 369 | |
| 370 | plt.style.use('ggplot') |
| 371 | |
| 372 | # Fixing random state for reproducibility |
| 373 | np.random.seed(19680801) |
| 374 | |
| 375 | fig, axes = plt.subplots(ncols=2, nrows=2) |
| 376 | ax1, ax2, ax3, ax4 = axes.ravel() |
| 377 | |
| 378 | # scatter plot (Note: `plt.scatter` doesn't use default colors) |
| 379 | x, y = np.random.normal(size=(2, 200)) |
| 380 | ax1.plot(x, y, 'o') |
| 381 | |
| 382 | # sinusoidal lines with colors from default color cycle |
| 383 | L = 2 * np.pi |
| 384 | x = np.linspace(0, L) |
| 385 | ncolors = len(plt.rcParams['axes.prop_cycle']) |
| 386 | shift = np.linspace(0, L, ncolors, endpoint=False) |
| 387 | for s in shift: |
| 388 | ax2.plot(x, np.sin(x + s), '-') |
| 389 | ax2.margins(0) |
| 390 | |
| 391 | # bar graphs |
| 392 | x = np.arange(5) |
| 393 | y1, y2 = np.random.randint(1, 25, size=(2, 5)) |
| 394 | width = 0.25 |
| 395 | ax3.bar(x, y1, width) |
| 396 | ax3.bar(x + width, y2, width, |
| 397 | color=list(plt.rcParams['axes.prop_cycle'])[2]['color']) |
| 398 | ax3.set_xticks(x + width) |
| 399 | ax3.set_xticklabels(['a', 'b', 'c', 'd', 'e']) |
| 400 | |
| 401 | # circles with colors from default color cycle |
| 402 | for i, color in enumerate(plt.rcParams['axes.prop_cycle']): |
| 403 | xy = np.random.normal(size=2) |
| 404 | ax4.add_patch(plt.Circle(xy, radius=0.3, color=color['color'])) |
| 405 | ax4.axis('equal') |
| 406 | ax4.margins(0) |
| 407 | fig = plt.gcf() # get the figure to show |
| 408 | return fig |
| 409 | |
| 410 | def PyplotBoxPlot(): |
| 411 | import numpy as np |