Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4f2f4de

Browse filesBrowse files
authored
Merge pull request #20505 from rcomer/docs-rcparams-context-manager
Add rc_context to customizing tutorial
2 parents fd8c5d2 + 390bf70 commit 4f2f4de
Copy full SHA for 4f2f4de

File tree

Expand file treeCollapse file tree

2 files changed

+22
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-1
lines changed

‎examples/lines_bars_and_markers/linestyles.py

Copy file name to clipboardExpand all lines: examples/lines_bars_and_markers/linestyles.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
linestyle_str = [
2121
('solid', 'solid'), # Same as (0, ()) or '-'
22-
('dotted', 'dotted'), # Same as (0, (1, 1)) or '.'
22+
('dotted', 'dotted'), # Same as (0, (1, 1)) or ':'
2323
('dashed', 'dashed'), # Same as '--'
2424
('dashdot', 'dashdot')] # Same as '-.'
2525

‎tutorials/introductory/customizing.py

Copy file name to clipboardExpand all lines: tutorials/introductory/customizing.py
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,27 @@
138138
mpl.rc('lines', linewidth=4, linestyle='-.')
139139
plt.plot(data)
140140

141+
###############################################################################
142+
# Temporary rc settings
143+
# ---------------------
144+
#
145+
# The :data:`matplotlib.rcParams` object can also be changed temporarily using
146+
# the `matplotlib.rc_context` context manager:
147+
148+
with mpl.rc_context({'lines.linewidth': 2, 'lines.linestyle': ':'}):
149+
plt.plot(data)
150+
151+
###############################################################################
152+
# `matplotlib.rc_context` can also be used as a decorator to modify the
153+
# defaults within a function:
154+
155+
156+
@mpl.rc_context({'lines.linewidth': 3, 'lines.linestyle': '-'})
157+
def plotting_function():
158+
plt.plot(data)
159+
160+
plotting_function()
161+
141162
###############################################################################
142163
# `matplotlib.rcdefaults` will restore the standard Matplotlib
143164
# default settings.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.