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

Skip to content

Commit 182354b

Browse files
committed
Merge pull request #6424 from efiring/legend_defaults
API: Legend default style change: smaller, no border
2 parents 4bbf4c9 + 6c4b973 commit 182354b

File tree

5 files changed

+34
-33
lines changed

5 files changed

+34
-33
lines changed

lib/matplotlib/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ def matplotlib_fname():
861861
_deprecated_ignore_map = {
862862
}
863863

864-
_obsolete_set = set(['tk.pythoninspect', ])
864+
_obsolete_set = set(['tk.pythoninspect', 'legend.isaxes'])
865865
_all_deprecated = set(chain(_deprecated_ignore_map,
866866
_deprecated_map, _obsolete_set))
867867

@@ -880,6 +880,8 @@ class RcParams(dict):
880880
if key not in _all_deprecated)
881881
msg_depr = "%s is deprecated and replaced with %s; please use the latter."
882882
msg_depr_ignore = "%s is deprecated and ignored. Use %s"
883+
msg_obsolete = ("%s is obsolete. Please remove it from your matplotlibrc "
884+
"and/or style files.")
883885

884886
# validate values on the way in
885887
def __init__(self, *args, **kwargs):
@@ -897,6 +899,9 @@ def __setitem__(self, key, val):
897899
alt = _deprecated_ignore_map[key]
898900
warnings.warn(self.msg_depr_ignore % (key, alt))
899901
return
902+
elif key in _obsolete_set:
903+
warnings.warn(self.msg_obsolete % (key,))
904+
return
900905
try:
901906
cval = self.validate[key](val)
902907
except ValueError as ve:
@@ -918,6 +923,10 @@ def __getitem__(self, key):
918923
warnings.warn(self.msg_depr_ignore % (key, alt))
919924
key = alt
920925

926+
elif key in _obsolete_set:
927+
warnings.warn(self.msg_obsolete % (key,))
928+
return None
929+
921930
val = dict.__getitem__(self, key)
922931
if inverse_alt is not None:
923932
return inverse_alt(val)

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ grid.alpha : 1.0 # transparency, between 0.0 and 1.0
267267
legend.fancybox : False # if True, use a rounded box for the
268268
# legend, else a rectangle
269269
legend.loc : upper right
270-
legend.isaxes : True # this option is internally ignored
271270
legend.numpoints : 2 # the number of points in the legend line
272271
legend.fontsize : large
273272
legend.borderpad : 0.4 # border whitespace in fontsize units
@@ -503,4 +502,4 @@ animation.convert_path: convert # Path to ImageMagick's convert binary.
503502
animation.convert_args:
504503
animation.html: none
505504

506-
_internal.classic_mode: True
505+
_internal.classic_mode: True

lib/matplotlib/rcsetup.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,25 +1102,19 @@ def validate_hist_bins(s):
11021102

11031103
#legend properties
11041104
'legend.fancybox': [True, validate_bool],
1105-
1106-
# at some point, legend.loc should be changed to 'best'
11071105
'legend.loc': ['best', validate_legend_loc],
1108-
1109-
# this option is internally ignored - it never served any useful purpose
1110-
'legend.isaxes': [True, validate_bool],
1111-
11121106
# the number of points in the legend line
11131107
'legend.numpoints': [1, validate_int],
11141108
# the number of points in the legend line for scatter
1115-
'legend.scatterpoints': [3, validate_int],
1116-
'legend.fontsize': ['large', validate_fontsize],
1109+
'legend.scatterpoints': [1, validate_int],
1110+
'legend.fontsize': ['medium', validate_fontsize],
11171111
# the relative size of legend markers vs. original
11181112
'legend.markerscale': [1.0, validate_float],
11191113
'legend.shadow': [False, validate_bool],
11201114
# whether or not to draw a frame around legend
11211115
'legend.frameon': [True, validate_bool],
11221116
# alpha value of the legend frame
1123-
'legend.framealpha': [None, validate_float_or_None],
1117+
'legend.framealpha': [0.8, validate_float_or_None],
11241118

11251119
## the following dimensions are in fraction of the font size
11261120
'legend.borderpad': [0.4, validate_float], # units are fontsize
@@ -1140,7 +1134,7 @@ def validate_hist_bins(s):
11401134
'legend.markerscale': [1.0, validate_float],
11411135
'legend.shadow': [False, validate_bool],
11421136
'legend.facecolor': ['inherit', validate_color_or_inherit],
1143-
'legend.edgecolor': ['k', validate_color_or_inherit],
1137+
'legend.edgecolor': ['none', validate_color_or_inherit],
11441138

11451139
# tick properties
11461140
'xtick.top': [True, validate_bool], # draw ticks on the top side

matplotlibrc.template

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -388,33 +388,32 @@ backend : $TEMPLATE_BACKEND
388388

389389

390390
### GRIDS
391-
#grid.color : b0b0b0 # grid color
391+
#grid.color : b0b0b0 # grid color
392392
#grid.linestyle : - # solid
393393
#grid.linewidth : 1.0 # in points
394394
#grid.alpha : 1.0 # transparency, between 0.0 and 1.0
395395

396396
### Legend
397-
#legend.fancybox : True # if True, use a rounded box for the
398-
# legend, else a rectangle
399397
#legend.loc : best
400-
#legend.isaxes : True
401-
#legend.numpoints : 1 # the number of points in the legend line
402-
#legend.fontsize : large
403-
#legend.borderpad : 0.5 # border whitespace in fontsize units
404-
#legend.markerscale : 1.0 # the relative size of legend markers vs. original
405-
# the following dimensions are in axes coords
406-
#legend.labelspacing : 0.5 # the vertical space between the legend entries in fraction of fontsize
407-
#legend.handlelength : 2. # the length of the legend lines in fraction of fontsize
408-
#legend.handleheight : 0.7 # the height of the legend handle in fraction of fontsize
409-
#legend.handletextpad : 0.8 # the space between the legend line and legend text in fraction of fontsize
410-
#legend.borderaxespad : 0.5 # the border between the axes and legend edge in fraction of fontsize
411-
#legend.columnspacing : 2. # the border between the axes and legend edge in fraction of fontsize
398+
#legend.frameon : True # whether or not to draw a frame around legend
399+
#legend.framealpha : 0.8 # legend frame transparency
400+
#legend.facecolor : inherit # inherit from axes.facecolor; or color spec
401+
#legend.edgecolor : none
402+
#legend.fancybox : True # if True, use a rounded box for the
403+
# legend, else a rectangle
412404
#legend.shadow : False
413-
#legend.frameon : True # whether or not to draw a frame around legend
414-
#legend.framealpha : None # opacity of of legend frame
415-
#legend.scatterpoints : 3 # number of scatter points
416-
#legend.facecolor : inherit
417-
#legend.edgecolor : k
405+
#legend.numpoints : 1 # the number of marker points in the legend line
406+
#legend.scatterpoints : 1 # number of scatter points
407+
#legend.markerscale : 1.0 # the relative size of legend markers vs. original
408+
#legend.fontsize : medium
409+
# Dimensions as fraction of fontsize:
410+
#legend.borderpad : 0.4 # border whitespace
411+
#legend.labelspacing : 0.5 # the vertical space between the legend entries
412+
#legend.handlelength : 2.0 # the length of the legend lines
413+
#legend.handleheight : 0.7 # the height of the legend handle
414+
#legend.handletextpad : 0.8 # the space between the legend line and legend text
415+
#legend.borderaxespad : 0.5 # the border between the axes and legend edge
416+
#legend.columnspacing : 2.0 # column separation
418417

419418
### FIGURE
420419
# See http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure

0 commit comments

Comments
 (0)