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

Skip to content

Legend default style change: smaller, no border #6424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ def matplotlib_fname():
_deprecated_ignore_map = {
}

_obsolete_set = set(['tk.pythoninspect', ])
_obsolete_set = set(['tk.pythoninspect', 'legend.isaxes'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need 2.6 support, right? You could use a set literal here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

_all_deprecated = set(chain(_deprecated_ignore_map,
_deprecated_map, _obsolete_set))

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

# validate values on the way in
def __init__(self, *args, **kwargs):
Expand All @@ -897,6 +899,9 @@ def __setitem__(self, key, val):
alt = _deprecated_ignore_map[key]
warnings.warn(self.msg_depr_ignore % (key, alt))
return
elif key in _obsolete_set:
warnings.warn(self.msg_obsolete % (key,))
return
try:
cval = self.validate[key](val)
except ValueError as ve:
Expand All @@ -918,6 +923,10 @@ def __getitem__(self, key):
warnings.warn(self.msg_depr_ignore % (key, alt))
key = alt

elif key in _obsolete_set:
warnings.warn(self.msg_obsolete % (key,))
return None

val = dict.__getitem__(self, key)
if inverse_alt is not None:
return inverse_alt(val)
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/mpl-data/stylelib/classic.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ grid.alpha : 1.0 # transparency, between 0.0 and 1.0
legend.fancybox : False # if True, use a rounded box for the
# legend, else a rectangle
legend.loc : upper right
legend.isaxes : True # this option is internally ignored
legend.numpoints : 2 # the number of points in the legend line
legend.fontsize : large
legend.borderpad : 0.4 # border whitespace in fontsize units
Expand Down Expand Up @@ -503,4 +502,4 @@ animation.convert_path: convert # Path to ImageMagick's convert binary.
animation.convert_args:
animation.html: none

_internal.classic_mode: True
_internal.classic_mode: True
14 changes: 4 additions & 10 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,25 +1102,19 @@ def validate_hist_bins(s):

#legend properties
'legend.fancybox': [True, validate_bool],

# at some point, legend.loc should be changed to 'best'
'legend.loc': ['best', validate_legend_loc],

# this option is internally ignored - it never served any useful purpose
'legend.isaxes': [True, validate_bool],

# the number of points in the legend line
'legend.numpoints': [1, validate_int],
# the number of points in the legend line for scatter
'legend.scatterpoints': [3, validate_int],
'legend.fontsize': ['large', validate_fontsize],
'legend.scatterpoints': [1, validate_int],
'legend.fontsize': ['medium', validate_fontsize],
# the relative size of legend markers vs. original
'legend.markerscale': [1.0, validate_float],
'legend.shadow': [False, validate_bool],
# whether or not to draw a frame around legend
'legend.frameon': [True, validate_bool],
# alpha value of the legend frame
'legend.framealpha': [None, validate_float_or_None],
'legend.framealpha': [0.8, validate_float_or_None],

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

# tick properties
'xtick.top': [True, validate_bool], # draw ticks on the top side
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 19 additions & 20 deletions matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -388,33 +388,32 @@ backend : $TEMPLATE_BACKEND


### GRIDS
#grid.color : b0b0b0 # grid color
#grid.color : b0b0b0 # grid color
#grid.linestyle : - # solid
#grid.linewidth : 1.0 # in points
#grid.alpha : 1.0 # transparency, between 0.0 and 1.0

### Legend
#legend.fancybox : True # if True, use a rounded box for the
# legend, else a rectangle
#legend.loc : best
#legend.isaxes : True
#legend.numpoints : 1 # the number of points in the legend line
#legend.fontsize : large
#legend.borderpad : 0.5 # border whitespace in fontsize units
#legend.markerscale : 1.0 # the relative size of legend markers vs. original
# the following dimensions are in axes coords
#legend.labelspacing : 0.5 # the vertical space between the legend entries in fraction of fontsize
#legend.handlelength : 2. # the length of the legend lines in fraction of fontsize
#legend.handleheight : 0.7 # the height of the legend handle in fraction of fontsize
#legend.handletextpad : 0.8 # the space between the legend line and legend text in fraction of fontsize
#legend.borderaxespad : 0.5 # the border between the axes and legend edge in fraction of fontsize
#legend.columnspacing : 2. # the border between the axes and legend edge in fraction of fontsize
#legend.frameon : True # whether or not to draw a frame around legend
#legend.framealpha : 0.8 # legend frame transparency
#legend.facecolor : inherit # inherit from axes.facecolor; or color spec
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this not a thing anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I don't know how long it has been gone, but it is inactive, and marked as such in rcsetup. It would make no sense for it to be an rcParam; it is entirely internal to legend. It is a flag to tell whether it is a figure legend or an axes legend.
Probably the validator for it should emit a warning.

#legend.edgecolor : none
#legend.fancybox : True # if True, use a rounded box for the
# legend, else a rectangle
#legend.shadow : False
#legend.frameon : True # whether or not to draw a frame around legend
#legend.framealpha : None # opacity of of legend frame
#legend.scatterpoints : 3 # number of scatter points
#legend.facecolor : inherit
#legend.edgecolor : k
#legend.numpoints : 1 # the number of marker points in the legend line
#legend.scatterpoints : 1 # number of scatter points
#legend.markerscale : 1.0 # the relative size of legend markers vs. original
#legend.fontsize : medium
# Dimensions as fraction of fontsize:
#legend.borderpad : 0.4 # border whitespace
#legend.labelspacing : 0.5 # the vertical space between the legend entries
#legend.handlelength : 2.0 # the length of the legend lines
#legend.handleheight : 0.7 # the height of the legend handle
#legend.handletextpad : 0.8 # the space between the legend line and legend text
#legend.borderaxespad : 0.5 # the border between the axes and legend edge
#legend.columnspacing : 2.0 # column separation

### FIGURE
# See http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure
Expand Down