8000 DOC: add section on `plot` · matplotlib/matplotlib@b6e9648 · GitHub
[go: up one dir, main page]

Skip to content

Commit b6e9648

Browse files
committed
DOC: add section on plot
1 parent 6f43449 commit b6e9648

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

doc/users/dflt_style_changes.rst

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,68 @@ The following changes were made to the default behavior of
256256
- the default linewidth change from 1 to 1.5
257257
- the dash patterns associated with ``'--'``, ``':'``, and ``'-.'`` have
258258
changed
259-
- the dash patterns now scale with line width.
259+
- the dash patterns now scale with line width
260260

261261

262+
.. plot::
263+
264+
import numpy as np
265+
import matplotlib.pyplot as plt
266+
import matplotlib as mpl
267+
from cycler import cycler
268+
269+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3))
270+
271+
N = 15
272+
273+
x = np.arange(N)
274+
y = np.ones_like(x)
275+
276+
sty_cycle = (cycler('ls', ['--' ,':', '-.']) *
277+
cycler('lw', [None, 1, 2, 5]))
278+
279+
classic = {
280+
'lines.linewidth': 1.0,
281+
'lines.dashed_pattern' : [6, 6],
282+
'lines.dashdot_pattern' : [3, 5, 1, 5],
283+
'lines.dotted_pattern' : [1, 3],
284+
'lines.scale_dashes': False}
285+
286+
v2 = {}
287+
# {'lines.linewidth': 1.5,
288+
# 'lines.dashed_pattern' : [2.8, 1.2],
289+
# 'lines.dashdot_pattern' : [4.8, 1.2, 0.8, 1.2],
290+
# 'lines.dotted_pattern' : [1.1, 1.1],
291+
# 'lines.scale_dashes': True}
292+
293+
def demo(ax, rcparams, title):
294+
ax.axis('off')
295+
ax.set_title(title)
296+
with mpl.rc_context(rc=rcparams):
297+
for j, sty in enumerate(sty_cycle):
298+
ax.plot(x, y + j, **sty)
299+
300+
demo(ax1, classic, 'classic')
301+
demo(ax2, {}, 'v2.0')
302+
303+
304+
The previous defaults can be restored by setting::
305+
306+
mpl.rcParams['lines.linewidth'] = 1.0
307+
mpl.rcParams['lines.dashed_pattern'] = [6, 6]
308+
mpl.rcParams['lines.dashdot_pattern'] = [3, 5, 1, 5]
309+
mpl.rcParams['lines.dotted_pattern'] = [1, 3]
310+
mpl.rcParams['lines.scale_dashes'] = False
311+
312+
or by setting::
313+
314+
lines.linewidth : 1.0
315+
lines.dashed_pattern : 6, 6
316+
lines.dashdot_pattern : 3, 5, 1, 5
317+
lines.dotted_pattern : 1, 3
318+
lines.scale_dashes: False
319+
320+
in your :file:`matplotlibrc` file.
262321

263322
Other
264323
=====

0 commit comments

Comments
 (0)
0