You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7a60e85
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: lectures/matplotlib.md
+29-11Lines changed: 29 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -372,24 +372,42 @@ Set parameters for your style sheet by:
372
372
1. creating your own [`matplotlibrc` file](https://matplotlib.org/stable/tutorials/introductory/customizing.html#defining-your-own-style), or
373
373
2. updating values stored in the dictionary-like variable `plt.rcParams`
374
374
375
-
Let's change the style of our overlaid density lines
375
+
Let's change the style of our overlaid density lines using the second method
376
376
377
377
```{code-cell} python3
378
378
from cycler import cycler
379
379
380
380
# set to the default style sheet
381
381
plt.style.use('default')
382
382
383
-
#set default figure size
384
-
plt.rcParams['figure.figsize'] = (10, 6)
385
-
# update linewidth
383
+
# You can update single values using keys:
384
+
385
+
# Set the font style to italic
386
+
plt.rcParams['font.style'] = 'italic'
387
+
388
+
# Update linewidth
386
389
plt.rcParams['lines.linewidth'] = 2
387
-
# add horizontal grid lines
388
-
plt.rcParams['axes.grid'] = True
389
-
plt.rcParams['axes.grid.axis'] = 'y'
390
-
# update colors for density lines
391
-
plt.rcParams['axes.prop_cycle'] = cycler('color',
392
-
['dimgray', 'slategrey', 'darkgray'])
390
+
391
+
392
+
# You can also update many values at once using the update() method:
393
+
394
+
parameters = {
395
+
396
+
# Change default figure size
397
+
'figure.figsize': (5, 4),
398
+
399
+
# Add horizontal grid lines
400
+
'axes.grid': True,
401
+
'axes.grid.axis': 'y',
402
+
403
+
# Update colors for density lines
404
+
'axes.prop_cycle': cycler('color',
405
+
['dimgray', 'slategrey', 'darkgray'])
406
+
}
407
+
408
+
plt.rcParams.update(parameters)
409
+
410
+
393
411
```
394
412
395
413
```{note}
@@ -418,7 +436,7 @@ Apply the `default` style sheet again to change your style back to default
0 commit comments