Customizing with rcParams
Matplotlib is a Python library for creating charts and visualizations — and rcParams is the global settings dictionary that controls how every one of those charts looks by default.
Learn Customizing with rcParams in our free Matplotlib course — a beginner-friendly interactive lesson with worked examples, a practice exercise and a quick…
Part of the free Matplotlib course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
In this lesson you'll change defaults like figure size, font size, and line width once, so every chart you draw afterward inherits your style automatically.
rcParams ("runtime configuration parameters") is a big dictionary holding every default Matplotlib uses. Change a value here and it becomes the new default for all charts you draw next.
Set a couple of defaults, then draw a chart that inherits them:
What you'll see: a line chart that is noticeably wider (8×5 inches) with larger title and tick text (12-point font). You didn't pass figsize to this plot — it inherited the default you set in rcParams.
Setting keys one at a time gets repetitive. plt.rcParams.update() takes a dictionary so you can apply a whole theme in one call. You can also reach rcParams through matplotlib itself as mpl.rcParams .
What you'll see: a thicker line (width 2) on a chart that now has light grid lines behind it — because axes.grid was switched on globally. Every future plot in this session keeps the grid until you change it back.
Because rcParams changes are global and sticky, you sometimes want a clean slate. plt.rcdefaults() restores every setting to Matplotlib's factory values.
What you'll see: a normal-looking chart with a thin line and standard font — even though you set a chunky 5-point line width and giant 20-point font just above. rcdefaults() wiped those customizations before the plot was drawn.
Replace each ___ to set a global figure size and enable grids.
The full key is 'figure.figsize' , not just 'figsize' . rcParams keys are dotted strings — check the exact name.
Set rcParams before you create the figure. Changing a default after a chart already exists won't restyle it.
Apply a custom theme with update(), draw a chart, then reset the defaults.
Lesson 19 complete — you control Matplotlib's global style!
You set global defaults through rcParams, applied a whole theme with update(), enabled grids everywhere, and reset to factory settings with rcdefaults().
🚀 Up next: Capstone — Build a Dashboard — combine everything you've learned into one polished, multi-chart figure.
Practice quiz
What is rcParams in Matplotlib?
- A list of chart types
- The global configuration dictionary of defaults
- A plotting function
- A colormap
Answer: The global configuration dictionary of defaults. rcParams holds every global default Matplotlib uses for new charts.
How do you set the default font size to 12?
- font.size
Answer: font.size. Assign to the key: plt.rcParams['font.size'] = 12.
Which method sets several rcParams at once?
- plt.rcParams.set_all()
- plt.rcParams.batch()
- plt.rcParams.update({...})
- plt.rcParams.many()
Answer: plt.rcParams.update({...}). plt.rcParams.update() takes a dictionary to apply a whole theme at once.
What is the full key for the default figure size?
- 'figsize'
- 'figure.size'
- 'fig.figsize'
- 'figure.figsize'
Answer: 'figure.figsize'. The dotted key is 'figure.figsize'; just 'figsize' raises KeyError.
Which call resets every rcParam to factory defaults?
- plt.rcdefaults()
- plt.reset()
- plt.clear_rc()
- plt.rcParams.clear()
Answer: plt.rcdefaults(). plt.rcdefaults() restores Matplotlib's original default settings.
Which rcParams key turns the grid on for every chart?
- 'grid.on'
- 'axes.grid'
- 'show.grid'
- 'grid.visible'
Answer: 'axes.grid'. Set plt.rcParams['axes.grid'] = True to show grids globally.
When should you set rcParams to affect a chart?
- After plt.show()
- It does not matter when
- Before you create the figure
- Only inside plt.plot()
Answer: Before you create the figure. Set rcParams before creating the figure; changes after won't restyle it.
Which key sets the default line thickness?
- 'lines.width'
- 'line.thickness'
- 'linewidth'
- 'lines.linewidth'
Answer: 'lines.linewidth'. plt.rcParams['lines.linewidth'] controls the default line width.
How are plt.rcParams and mpl.rcParams related?
- They are the exact same object
- mpl.rcParams is read-only
- They are unrelated
- plt.rcParams is faster
Answer: They are the exact same object. Both names point to the very same configuration object.
What raises KeyError: 'figsize'?
- Using rcParams.update
- Using the key 'figsize' instead of 'figure.figsize'
- Setting font.size
- Calling rcdefaults
Answer: Using the key 'figsize' instead of 'figure.figsize'. rcParams keys are dotted strings; the correct key is 'figure.figsize'.