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 ecce9a1

Browse filesBrowse files
committed
Merge pull request #4218 from Mrngilles/master
ENH: Addition of RC parameters
2 parents 29b5d1d + 6d9c2f8 commit ecce9a1
Copy full SHA for ecce9a1

File tree

Expand file treeCollapse file tree

11 files changed

+1411
-18
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+1411
-18
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+59-11Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,19 +2950,19 @@ def xywhere(xs, ys, mask):
29502950

29512951
return errorbar_container # (l0, caplines, barcols)
29522952

2953-
def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,
2954-
positions=None, widths=None, patch_artist=False,
2953+
def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
2954+
positions=None, widths=None, patch_artist=None,
29552955
bootstrap=None, usermedians=None, conf_intervals=None,
2956-
meanline=False, showmeans=False, showcaps=True,
2957-
showbox=True, showfliers=True, boxprops=None, labels=None,
2956+
meanline=None, showmeans=None, showcaps=None,
2957+
showbox=None, showfliers=None, boxprops=None, labels=None,
29582958
flierprops=None, medianprops=None, meanprops=None,
29592959
capprops=None, whiskerprops=None, manage_xticks=True):
29602960
"""
29612961
Make a box and whisker plot.
29622962
29632963
Call signature::
29642964
2965-
boxplot(self, x, notch=False, sym='b+', vert=True, whis=1.5,
2965+
boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
29662966
positions=None, widths=None, patch_artist=False,
29672967
bootstrap=None, usermedians=None, conf_intervals=None,
29682968
meanline=False, showmeans=False, showcaps=True,
@@ -3114,11 +3114,59 @@ def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,
31143114
31153115
.. plot:: mpl_examples/statistics/boxplot_demo.py
31163116
"""
3117+
# If defined in matplotlibrc, apply the value from rc file
3118+
# Overridden if argument is passed
3119+
if whis is None:
3120+
whis = rcParams['boxplot.whiskers']
3121+
if bootstrap is None:
3122+
bootstrap = rcParams['boxplot.bootstrap']
31173123
bxpstats = cbook.boxplot_stats(x, whis=whis, bootstrap=bootstrap,
31183124
labels=labels)
3119-
# make sure we have a dictionary
3120-
if flierprops is None:
3121-
flierprops = dict()
3125+
if notch is None:
3126+
notch = rcParams['boxplot.notch']
3127+
if vert is None:
3128+
vert = rcParams['boxplot.vertical']
3129+
if patch_artist is None:
3130+
patch_artist = rcParams['boxplot.patchartist']
3131+
if meanline is None:
3132+
meanline = rcParams['boxplot.meanline']
3133+
if showmeans is None:
3134+
showmeans = rcParams['boxplot.showmeans']
3135+
if showcaps is None:
3136+
showcaps = rcParams['boxplot.showcaps']
3137+
if showbox is None:
3138+
showbox = rcParams['boxplot.showbox']
3139+
if showfliers is None:
3140+
showfliers = rcParams['boxplot.showfliers']
3141+
3142+
def _update_dict(dictionary, rc_name, properties):
3143+
""" Loads properties in the dictionary from rc file if not already
3144+
in the dictionary"""
3145+
rc_str = 'boxplot.{0}.{1}'
3146+
if dictionary is None:
3147+
dictionary = dict()
3148+
for prop_dict in properties:
3149+
dictionary.setdefault(prop_dict,
3150+
rcParams[rc_str.format(rc_name, prop_dict)])
3151+
return dictionary
3152+
3153+
# Common property dictionnaries loading from rc
3154+
flier_props = ['color', 'marker', 'markerfacecolor', 'markeredgecolor',
3155+
'markersize', 'linestyle', 'linewidth']
3156+
default_props = ['color', 'linewidth', 'linestyle']
3157+
3158+
boxprops = _update_dict(boxprops, 'boxprops', default_props)
3159+
whiskerprops = _update_dict(whiskerprops, 'whiskerprops',
3160+
default_props)
3161+
capprops = _update_dict(capprops, 'capprops', default_props)
3162+
medianprops = _update_dict(medianprops, 'medianprops', default_props)
3163+
meanprops = _update_dict(meanprops, 'meanprops', default_props)
3164+
flierprops = _update_dict(flierprops, 'flierprops', flier_props)
3165+
3166+
if patch_artist:
3167+
boxprops['linestyle'] = 'solid'
3168+
boxprops['edgecolor'] = boxprops.pop('color')
3169+
31223170
# if non-default sym value, put it into the flier dictionary
31233171
# the logic for providing the default symbol ('b+') now lives
31243172
# in bxp in the initial value of final_flierprops
@@ -3162,8 +3210,8 @@ def boxplot(self, x, notch=False, sym=None, vert=True, whis=1.5,
31623210

31633211
if conf_intervals is not None:
31643212
if np.shape(conf_intervals)[0] != len(bxpstats):
3165-
raise ValueError('conf_intervals length not '
3166-
'compatible with x')
3213+
err_mess = 'conf_intervals length not compatible with x'
3214+
raise ValueError(err_mess)
31673215
else:
31683216
for stats, ci in zip(bxpstats, conf_intervals):
31693217
if ci is not None:
@@ -3680,7 +3728,7 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
36803728
if facecolors is not None:
36813729
c = facecolors
36823730
else:
3683-
c = 'b' # the original default
3731+
c = 'b' # The original default
36843732

36853733
self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
36863734
x = self.convert_xunits(x)

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,9 @@ def cla(self):
921921
self.collections = [] # collection.Collection instances
922922
self.containers = []
923923

924-
self.grid(self._gridOn, which=rcParams['axes.grid.which'])
924+
self.grid(False) # Disable grid on init to use rcParameter
925+
self.grid(self._gridOn, which=rcParams['axes.grid.which'],
926+
axis=rcParams['axes.grid.axis'])
925927
props = font_manager.FontProperties(
926928
size=rcParams['axes.titlesize'],
927929
weight=rcParams['axes.titleweight']

‎lib/matplotlib/mpl-data/stylelib/bmh.mplstyle

Copy file name to clipboardExpand all lines: lib/matplotlib/mpl-data/stylelib/bmh.mplstyle
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Author: Cameron Davidson-Pilon, original styles from Bayesian Methods for Hackers
2-
# https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/
2+
# https://github.com/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/
33

44
lines.linewidth : 2.0
55

@@ -19,4 +19,5 @@ axes.titlesize: x-large
1919
axes.labelsize: large
2020
axes.color_cycle: 348ABD, A60628, 7A68A6, 467821, D55E00, CC79A7, 56B4E9, 009E73, F0E442, 0072B2
2121

22-
legend.fancybox: True
22+
legend.fancybox: True
23+

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+75-1Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ def validate_int(s):
139139
except ValueError:
140140
raise ValueError('Could not convert "%s" to int' % s)
141141

142+
def validate_int_or_None(s):
143+
"""if not None, tries to validate as an int"""
144+
if s=='None':
145+
s = None
146+
if s is None:
147+
return None
148+
try:
149+
return int(s)
150+
except ValueError:
151+
raise ValueError('Could not convert "%s" to int' % s)
142152

143153
def validate_fonttype(s):
144154
"""
@@ -352,6 +362,22 @@ def validate_font_properties(s):
352362
'verbose',
353363
['silent', 'helpful', 'debug', 'debug-annoying'])
354364

365+
def validate_whiskers(s):
366+
if s=='range':
367+
return 'range'
368+
else:
369+
try:
370+
v = validate_nseq_float(2)(s)
371+
return v
372+
except:
373+
try:
374+
v = float(s)
375+
return v
376+
except:
377+
err_str = ("Not a valid whisker value ['range',"
378+
"float, (float, float)]")
379+
raise ValueError(err_str)
380+
355381

356382
def deprecate_savefig_extension(value):
357383
warnings.warn("savefig.extension is deprecated. Use savefig.format "
@@ -471,7 +497,7 @@ def validate_hinting(s):
471497
validate_movie_frame_fmt = ValidateInStrings('animation.frame_format',
472498
['png', 'jpeg', 'tiff', 'raw', 'rgba'])
473499

474-
validate_axis_locator = ValidateInStrings('major', ['minor','both','major'])
500+
validate_axis_locator = ValidateInStrings('major', ['minor', 'both', 'major'])
475501

476502
def validate_bbox(s):
477503
if isinstance(s, six.string_types):
@@ -530,6 +556,7 @@ def __call__(self, s):
530556
(self.vmax, s))
531557
return s
532558

559+
validate_grid_axis = ValidateInStrings('axes.grid.axis', ['x', 'y', 'both'])
533560

534561
# a map from key -> value, converter
535562
defaultParams = {
@@ -574,6 +601,45 @@ def __call__(self, s):
574601
'patch.facecolor': ['b', validate_color], # blue
575602
'patch.antialiased': [True, validate_bool], # antialised (no jaggies)
576603

604+
## Boxplot properties
605+
'boxplot.notch': [False, validate_bool],
606+
'boxplot.vertical': [True, validate_bool],
607+
'boxplot.whiskers': [1.5, validate_whiskers],
608+
'boxplot.bootstrap': [None, validate_int_or_None],
609+
'boxplot.patchartist': [False, validate_bool],
610+
'boxplot.showmeans': [False, validate_bool],
611+
'boxplot.showcaps': [True, validate_bool],
612+
'boxplot.showbox': [True, validate_bool],
613+
'boxplot.showfliers': [True, validate_bool],
614+
'boxplot.meanline': [False, validate_bool],
615+
616+
'boxplot.flierprops.color': ['b', validate_color],
617+
'boxplot.flierprops.marker': ['+', six.text_type],
618+
'boxplot.flierprops.markerfacecolor': ['b', validate_color],
619+
'boxplot.flierprops.markeredgecolor': ['k', validate_color],
620+
'boxplot.flierprops.markersize': [6, validate_float],
621+
'boxplot.flierprops.linestyle': ['-', six.text_type],
622+
'boxplot.flierprops.linewidth': [1.0, validate_float],
623+
624+
'boxplot.boxprops.color': ['b', validate_color],
625+
'boxplot.boxprops.linewidth': [1.0, validate_float],
626+
'boxplot.boxprops.linestyle': ['-', six.text_type],
627+
628+
'boxplot.whiskerprops.color': ['b', validate_color],
629+
'boxplot.whiskerprops.linewidth': [1.0, validate_float],
630+
'boxplot.whiskerprops.linestyle': ['--', six.text_type],
631+
632+
'boxplot.capprops.color': ['k', validate_color],
633+
'boxplot.capprops.linewidth': [1.0, validate_float],
634+
'boxplot.capprops.linestyle': ['-', six.text_type],
635+
636+
'boxplot.medianprops.color': ['r', validate_color],
637+
'boxplot.medianprops.linewidth': [1.0, validate_float],
638+
'boxplot.medianprops.linestyle': ['-', six.text_type],
639+
640+
'boxplot.meanprops.color': ['r', validate_color],
641+
'boxplot.meanprops.linewidth': [1.0, validate_float],
642+
'boxplot.meanprops.linestyle': ['-', six.text_type],
577643

578644
## font props
579645
'font.family': [['sans-serif'], validate_stringlist], # used by text object
@@ -648,6 +714,12 @@ def __call__(self, s):
648714
'axes.facecolor': ['w', validate_color], # background color; white
649715
'axes.edgecolor': ['k', validate_color], # edge color; black
650716
'axes.linewidth': [1.0, validate_float], # edge linewidth
717+
718+
'axes.spines.left': [True, validate_bool], # Set visibility of axes
719+
'axes.spines.right': [True, validate_bool], # 'spines', the lines
720+
'axes.spines.bottom': [True, validate_bool], # around the chart
721+
'axes.spines.top': [True, validate_bool], # denoting data boundary
722+
651723
'axes.titlesize': ['large', validate_fontsize], # fontsize of the
652724
# axes title
653725
'axes.titleweight': ['normal', six.text_type], # font weight of axes title
@@ -656,6 +728,8 @@ def __call__(self, s):
656728
# default draw on 'major'
657729
# 'minor' or 'both' kind of
658730
# axis locator
731+
'axes.grid.axis': ['both', validate_grid_axis], # grid type.
732+
# Can be 'x', 'y', 'both'
659733
'axes.labelsize': ['medium', validate_fontsize], # fontsize of the
660734
# x any y labels
661735
'axes.labelpad': [5.0, validate_float], # space between label and axis

‎lib/matplotlib/spines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/spines.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ def linear_spine(cls, axes, spine_type, **kwargs):
467467
else:
468468
raise ValueError('unable to make path for spine "%s"' % spine_type)
469469
result = cls(axes, spine_type, path, **kwargs)
470+
result.set_visible(rcParams['axes.spines.{0}'.format(spine_type)])
471+
470472
return result
471473

472474
@classmethod
Binary file not shown.
Loading

0 commit comments

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