|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "82fc7f4b", |
| 6 | + "metadata": { |
| 7 | + "lines_to_next_cell": 0 |
| 8 | + }, |
| 9 | + "source": [ |
| 10 | + "# Matplotlib Configuration\n", |
| 11 | + "\n", |
| 12 | + "Matplotlib Runtime Configuration (rc) allows you to customize the default styles and \n", |
| 13 | + "behaviors of plots. The rcParams dictionary stores these settings,\n", |
| 14 | + "such as font sizes, line widths,and color schemes.\n", |
| 15 | + "You can modify rcParams directly in your code to change the appearance of all plots globally.\n", |
| 16 | + "Example: `mpl.rcParams['lines.linewidth'] = 2.0`\n", |
| 17 | + "You can also use style sheets or the 'matplotlibrc' file for persistent configuration." |
| 18 | + ] |
| 19 | + }, |
| 20 | + { |
| 21 | + "cell_type": "code", |
| 22 | + "execution_count": null, |
| 23 | + "id": "9bcf6d84", |
| 24 | + "metadata": {}, |
| 25 | + "outputs": [], |
| 26 | + "source": [ |
| 27 | + "import matplotlib\n", |
| 28 | + "import matplotlib.font_manager\n", |
| 29 | + "\n", |
| 30 | + "print(matplotlib.rcParams['font.size']) # Default font size (usually 'medium')\n", |
| 31 | + "print(matplotlib.font_manager.font_scalings) # Shows the scaling factors for each size keyword" |
| 32 | + ] |
| 33 | + }, |
| 34 | + { |
| 35 | + "cell_type": "markdown", |
| 36 | + "id": "de009889", |
| 37 | + "metadata": {}, |
| 38 | + "source": [ |
| 39 | + "Find the full list of rcParams you can modify\n", |
| 40 | + "See the documentation [here] and specifically \n", |
| 41 | + "[`rcParams`](https://matplotlib.org/stable/api/matplotlib_configuration_api.html#matplotlib.rcParams)." |
| 42 | + ] |
| 43 | + }, |
| 44 | + { |
| 45 | + "cell_type": "code", |
| 46 | + "execution_count": null, |
| 47 | + "id": "d2460360", |
| 48 | + "metadata": { |
| 49 | + "lines_to_next_cell": 2 |
| 50 | + }, |
| 51 | + "outputs": [], |
| 52 | + "source": [ |
| 53 | + "matplotlib.rcParams['font.size'] = 14 # Set a new default font size" |
| 54 | + ] |
| 55 | + }, |
| 56 | + { |
| 57 | + "cell_type": "markdown", |
| 58 | + "id": "b8d59ddd", |
| 59 | + "metadata": {}, |
| 60 | + "source": [ |
| 61 | + "See them all below:" |
| 62 | + ] |
| 63 | + }, |
| 64 | + { |
| 65 | + "cell_type": "code", |
| 66 | + "execution_count": null, |
| 67 | + "id": "55cb182f", |
| 68 | + "metadata": {}, |
| 69 | + "outputs": [], |
| 70 | + "source": [ |
| 71 | + "matplotlib.rcParams" |
| 72 | + ] |
| 73 | + } |
| 74 | + ], |
| 75 | + "metadata": { |
| 76 | + "jupytext": { |
| 77 | + "cell_metadata_filter": "-all", |
| 78 | + "main_language": "python", |
| 79 | + "notebook_metadata_filter": "-all" |
| 80 | + } |
| 81 | + }, |
| 82 | + "nbformat": 4, |
| 83 | + "nbformat_minor": 5 |
| 84 | +} |
0 commit comments