Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4b63036

Browse files
committed
DOC: add errorbar example
1 parent 2aadcba commit 4b63036

1 file changed

Lines changed: 41 additions & 10 deletions

File tree

doc/users/dflt_style_changes.rst

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,44 @@ or by setting::
362362

363363
in your :file:`matplotlibrc` file.
364364

365-
Errorbar
366-
--------
365+
``errorbar``
366+
------------
367+
368+
By default, caps on the ends of errorbars are not present.
369+
370+
.. plot::
371+
372+
import matplotlib as mpl
373+
import matplotlib.pyplot as plt
374+
import numpy as np
375+
376+
# example data
377+
x = np.arange(0.1, 4, 0.5)
378+
y = np.exp(-x)
379+
380+
# example variable error bar values
381+
yerr = 0.1 + 0.2*np.sqrt(x)
382+
xerr = 0.1 + yerr
383+
384+
def demo(ax, rc, title):
385+
with mpl.rc_context(rc=rc):
386+
ax.errorbar(x, y, xerr=0.2, yerr=0.4)
387+
ax.set_title(title)
388+
389+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3), tight_layout=True)
390+
391+
demo(ax1, {'errorbar.capsize': 3}, 'classic')
392+
demo(ax2, {}, 'v2.0')
393+
394+
The previous defaults can be restored by setting::
395+
396+
mpl.rcParams['errorbar.capsize'] = 3
397+
398+
or by setting ::
367399

368-
- By default, caps on the ends of errorbars are not present. Use the
369-
rcParam ``errorbar.capsize`` to control this.
400+
errorbar.capsize : 3
401+
402+
in your :file:`matplotlibrc` file.
370403

371404

372405
Patch edges and color
@@ -587,8 +620,7 @@ Legends
587620
'legend.framealpha': None,
588621
'legend.edgecolor': 'inherit',
589622
'legend.loc': 'upper right',
590-
'legend.fontsize': 'large',
591-
}
623+
'legend.fontsize': 'large'}
592624

593625
demo(ax1, classic_rc, 'classic')
594626
demo(ax2, {}, 'v2.0')
@@ -730,8 +762,7 @@ porcupine.
730762
classic = {'xtick.direction': 'in',
731763
'ytick.direction': 'in',
732764
'xtick.top': True,
733-
'ytick.right': True
734-
}
765+
'ytick.right': True}
735766

736767
fig = plt.figure(figsize=(6, 6), tight_layout=True)
737768

@@ -892,8 +923,8 @@ Z-order
892923

893924

894925

895-
`~matplotlib.dates.AutoDateFormatter` format strings
896-
====================================================
926+
``AutoDateFormatter`` format strings
927+
====================================
897928

898929
The default date formats are now all based on ISO format, i.e., with
899930
the slowest-moving value first. The date formatters are

0 commit comments

Comments
 (0)