Skip to content

Commit 5c14f6a

Browse files
committed
✨ hint to matplotlib parameters
1 parent f3bf1ce commit 5c14f6a

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

1_4_matplotlib_config.ipynb

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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+
}

1_4_matplotlib_config.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# %% [markdown]
2+
# # Matplotlib Configuration
3+
#
4+
# Matplotlib Runtime Configuration (rc) allows you to customize the default styles and
5+
# behaviors of plots. The rcParams dictionary stores these settings,
6+
# such as font sizes, line widths,and color schemes.
7+
# You can modify rcParams directly in your code to change the appearance of all plots globally.
8+
# Example: `mpl.rcParams['lines.linewidth'] = 2.0`
9+
# You can also use style sheets or the 'matplotlibrc' file for persistent configuration.
10+
# %%
11+
import matplotlib
12+
import matplotlib.font_manager
13+
14+
print(matplotlib.rcParams['font.size']) # Default font size (usually 'medium')
15+
print(matplotlib.font_manager.font_scalings) # Shows the scaling factors for each size keyword
16+
17+
# %% [markdown]
18+
# Find the full list of rcParams you can modify
19+
# See the documentation [here] and specifically
20+
# [`rcParams`](https://matplotlib.org/stable/api/matplotlib_configuration_api.html#matplotlib.rcParams).
21+
22+
# %%
23+
matplotlib.rcParams['font.size'] = 14 # Set a new default font size
24+
25+
26+
# %% [markdown]
27+
# See them all below:
28+
29+
# %%
30+
matplotlib.rcParams

index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
1_2_pandas
2424
1_2_seaborn
2525
1_3_seaborn
26+
1_4_matplotlib_config
2627
2_plotly
2728
3_vuecore
2829
```

0 commit comments

Comments
 (0)