|
81 | 81 | { |
82 | 82 | "cell_type": "code", |
83 | 83 | "execution_count": null, |
84 | | - "id": "39e06d4b", |
| 84 | + "id": "a1c0a7c7-8de5-4356-a769-dd2d935f5195", |
85 | 85 | "metadata": { |
86 | 86 | "editable": true, |
87 | 87 | "remove_code": "non-comments", |
|
130 | 130 | "\n", |
131 | 131 | "# Plot the data on the subplots\n", |
132 | 132 | "\n", |
133 | | - "# Show plot\n" |
| 133 | + "# Show plot\n", |
| 134 | + "#plt.show()" |
134 | 135 | ] |
135 | 136 | }, |
136 | 137 | { |
|
190 | 191 | "# Add legends to the subplots\n", |
191 | 192 | "\n", |
192 | 193 | "# Adjust the spacing between subplots\n", |
| 194 | + "#fig.tight_layout()\n", |
193 | 195 | "\n", |
194 | | - "# Show the plot\n" |
| 196 | + "# Show the plot\n", |
| 197 | + "#plt.show()" |
195 | 198 | ] |
196 | 199 | }, |
197 | 200 | { |
|
260 | 263 | "\n", |
261 | 264 | "# Customize plot appearance using grid and legend\n", |
262 | 265 | "\n", |
263 | | - "# Show the plot\n" |
| 266 | + "# Show the plot\n", |
| 267 | + "#plt.show()" |
264 | 268 | ] |
265 | 269 | }, |
266 | 270 | { |
|
318 | 322 | "\n", |
319 | 323 | "# Demonstrate horizontal bar plot\n", |
320 | 324 | "\n", |
321 | | - "# Show the plot\n" |
| 325 | + "# Show the plot\n", |
| 326 | + "#plt.show()" |
322 | 327 | ] |
323 | 328 | }, |
324 | 329 | { |
|
365 | 370 | "\n", |
366 | 371 | "# Create sorted horizontal bar plot\n", |
367 | 372 | "\n", |
368 | | - "# Show the plot\n" |
| 373 | + "# Show the plot\n", |
| 374 | + "#plt.show()" |
369 | 375 | ] |
370 | 376 | }, |
371 | 377 | { |
|
405 | 411 | { |
406 | 412 | "cell_type": "code", |
407 | 413 | "execution_count": null, |
408 | | - "id": "86873b14-658d-41fc-b84e-75a8f60badb5", |
409 | | - "metadata": { |
410 | | - "remove_code": "non-comments" |
411 | | - }, |
| 414 | + "id": "4157aada-b18e-48b8-b1a8-0f74c94d554b", |
| 415 | + "metadata": {}, |
412 | 416 | "outputs": [], |
413 | 417 | "source": [ |
414 | | - "# Set the plot style\n" |
| 418 | + "# Set the plot style\n", |
| 419 | + "plt.style.use('../mpl_styles/colors.mplstyle')\n", |
| 420 | + "colors = ['C1', 'C1', 'C2', 'C2', 'C3', 'C4', 'C5']" |
415 | 421 | ] |
416 | 422 | }, |
417 | 423 | { |
|
433 | 439 | "\n", |
434 | 440 | "# Create the same sorted horizontal bar plot, but with colours\n", |
435 | 441 | "\n", |
436 | | - "# Show the plot\n" |
| 442 | + "# Show the plot\n", |
| 443 | + "#plt.show()" |
437 | 444 | ] |
438 | 445 | }, |
439 | 446 | { |
|
453 | 460 | { |
454 | 461 | "cell_type": "code", |
455 | 462 | "execution_count": null, |
456 | | - "id": "31f6e1b3", |
457 | | - "metadata": { |
458 | | - "remove_code": "non-comments" |
459 | | - }, |
| 463 | + "id": "3b91fd43-f4ff-4bf0-afbe-b913329f73fd", |
| 464 | + "metadata": {}, |
460 | 465 | "outputs": [], |
461 | 466 | "source": [ |
462 | 467 | "# Apply style to plot\n", |
463 | | - "\n", |
464 | | - " # Plot the data\n" |
| 468 | + "with plt.style.context(('../mpl_styles/presentation.mplstyle')):\n", |
| 469 | + " # Plot the data\n", |
| 470 | + " plt.plot(np.sin(np.linspace(0, 2 * np.pi)), 'C1-o')" |
465 | 471 | ] |
466 | 472 | }, |
467 | 473 | { |
468 | 474 | "cell_type": "code", |
469 | 475 | "execution_count": null, |
470 | | - "id": "d8235648", |
471 | | - "metadata": { |
472 | | - "remove_code": "non-comments" |
473 | | - }, |
| 476 | + "id": "b84d6086-fe3c-4fe7-8f67-58f35282e323", |
| 477 | + "metadata": {}, |
474 | 478 | "outputs": [], |
475 | 479 | "source": [ |
476 | 480 | "# Apply style to plot\n", |
477 | | - "\n", |
478 | | - " # Plot the data\n" |
| 481 | + "with plt.style.context((\n", |
| 482 | + " '../mpl_styles/publication.mplstyle',\n", |
| 483 | + " '../mpl_styles/publication_onecolumn.mplstyle')\n", |
| 484 | + "):\n", |
| 485 | + " # Plot the data\n", |
| 486 | + " plt.plot(np.sin(np.linspace(0, 2 * np.pi)), 'C2-o')" |
479 | 487 | ] |
480 | 488 | }, |
481 | 489 | { |
482 | 490 | "cell_type": "code", |
483 | 491 | "execution_count": null, |
484 | | - "id": "795750e0", |
485 | | - "metadata": { |
486 | | - "remove_code": "non-comments" |
487 | | - }, |
| 492 | + "id": "f4381929-f222-4f55-b895-c57ba25a3d06", |
| 493 | + "metadata": {}, |
488 | 494 | "outputs": [], |
489 | 495 | "source": [ |
490 | 496 | "# Apply style to plot\n", |
491 | | - "\n", |
492 | | - " # Plot the data\n" |
| 497 | + "with plt.style.context((\n", |
| 498 | + " '../mpl_styles/publication.mplstyle',\n", |
| 499 | + " '../mpl_styles/publication_twocolumn.mplstyle'\n", |
| 500 | + ")):\n", |
| 501 | + " # Plot the data\n", |
| 502 | + " plt.plot(np.sin(np.linspace(0, 2 * np.pi)), 'C2-o')" |
493 | 503 | ] |
494 | 504 | }, |
495 | 505 | { |
|
527 | 537 | "execution_count": null, |
528 | 538 | "id": "9e333843", |
529 | 539 | "metadata": { |
530 | | - "remove_code": "after:# Plot the data" |
| 540 | + "remove_code": "after:# Save the plot in a file" |
531 | 541 | }, |
532 | 542 | "outputs": [], |
533 | 543 | "source": [ |
|
543 | 553 | " fig, ax = plt.subplots()\n", |
544 | 554 | "\n", |
545 | 555 | " # Plot the data\n", |
| 556 | + " ax.plot(x, np.sin(x), 'C2')\n", |
| 557 | + " ax.set_xlabel('$x$')\n", |
| 558 | + " ax.set_ylabel(r'$\\sin(x)$ / a. u.')\n", |
546 | 559 | "\n", |
547 | 560 | " # Save the plot in a file\n" |
548 | 561 | ] |
|
0 commit comments