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

Skip to content

Commit f88114c

Browse files
committed
No edges on filled patches by default
1 parent 62df86d commit f88114c

File tree

6 files changed

+53
-14
lines changed

6 files changed

+53
-14
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,7 @@ def bar(self, left, height, width=0.8, bottom=None, **kwargs):
19861986
xerr = kwargs.pop('xerr', None)
19871987
yerr = kwargs.pop('yerr', None)
19881988
error_kw = kwargs.pop('error_kw', dict())
1989-
ecolor = kwargs.pop('ecolor', None)
1989+
ecolor = kwargs.pop('ecolor', 'k')
19901990
capsize = kwargs.pop('capsize', rcParams["errorbar.capsize"])
19911991
error_kw.setdefault('ecolor', ecolor)
19921992
error_kw.setdefault('capsize', capsize)
@@ -3875,6 +3875,7 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
38753875
marker_obj.get_transform())
38763876
if not marker_obj.is_filled():
38773877
edgecolors = 'face'
3878+
linewidths = rcParams['lines.linewidth']
38783879

38793880
offsets = np.dstack((x, y))
38803881

@@ -4018,9 +4019,9 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
40184019
the alpha value for the patches
40194020
40204021
*linewidths*: [ *None* | scalar ]
4021-
If *None*, defaults to rc lines.linewidth. Note that this
4022-
is a tuple, and if you set the linewidths argument you
4023-
must set it as a sequence of floats, as required by
4022+
If *None*, defaults to 1.0. Note that this is a tuple, and
4023+
if you set the linewidths argument you must set it as a
4024+
sequence of floats, as required by
40244025
:class:`~matplotlib.collections.RegularPolyCollection`.
40254026
40264027
Other keyword arguments controlling the Collection properties:
@@ -4213,6 +4214,8 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
42134214

42144215
if edgecolors == 'none':
42154216
edgecolors = 'face'
4217+
if linewidths is None:
4218+
linewidths = [1.0]
42164219

42174220
if xscale == 'log' or yscale == 'log':
42184221
polygons = np.expand_dims(polygon, 0) + np.expand_dims(offsets, 1)

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def _makefill(self, x, y, kw, kwargs):
325325
seg = mpatches.Polygon(np.hstack((x[:, np.newaxis],
326326
y[:, np.newaxis])),
327327
facecolor=facecolor,
328-
fill=True,
328+
fill=kwargs.get('fill', True),
329329
closed=kw['closed'])
330330
self.set_patchprops(seg, **kwargs)
331331
return seg

lib/matplotlib/collections.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class Collection(artist.Artist, cm.ScalarMappable):
8888
#: Each kind of collection defines this based on its arguments.
8989
_transforms = np.empty((0, 3, 3))
9090

91+
# Whether to draw an edge by default. Set on a
92+
# subclass-by-subclass basis.
93+
_edge_default = False
94+
9195
def __init__(self,
9296
edgecolors=None,
9397
facecolors=None,
@@ -476,7 +480,15 @@ def set_linewidth(self, lw):
476480
ACCEPTS: float or sequence of floats
477481
"""
478482
if lw is None:
479-
lw = mpl.rcParams['patch.linewidth']
483+
if (self._edge_default or
484+
mpl.rcParams['_internal.classic_mode'] or
485+
not self._is_filled):
486+
lw = mpl.rcParams['patch.linewidth']
487+
if lw is None:
488+
lw = mpl.rcParams['lines.linewidth']
489+
else:
490+
lw = 0
491+
480492
self._linewidths = self._get_value(lw)
481493
self.stale = True
482494

@@ -1046,6 +1058,8 @@ class LineCollection(Collection):
10461058
number of segments.
10471059
"""
10481060

1061+
_edge_default = True
1062+
10491063
def __init__(self, segments, # Can be None.
10501064
linewidths=None,
10511065
colors=None,
@@ -1217,6 +1231,8 @@ class EventCollection(LineCollection):
12171231
are displayed as v
12181232
'''
12191233

1234+
_edge_default = True
1235+
12201236
def __init__(self,
12211237
positions, # Can be None.
12221238
orientation=None,

lib/matplotlib/patches.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ class Patch(artist.Artist):
6767
validCap = ('butt', 'round', 'projecting')
6868
validJoin = ('miter', 'round', 'bevel')
6969

70+
# Whether to draw an edge by default. Set on a
71+
# subclass-by-subclass basis.
72+
_edge_default = False
73+
7074
def __str__(self):
7175
return str(self.__class__).split('.')[-1]
7276

@@ -110,11 +114,12 @@ def __init__(self,
110114
else:
111115
self.set_edgecolor(edgecolor)
112116
self.set_facecolor(facecolor)
117+
118+
self.set_fill(fill)
113119
self.set_linewidth(linewidth)
114120
self.set_linestyle(linestyle)
115121
self.set_antialiased(antialiased)
116122
self.set_hatch(hatch)
117-
self.set_fill(fill)
118123
self.set_capstyle(capstyle)
119124
self.set_joinstyle(joinstyle)
120125
self._combined_transform = transforms.IdentityTransform()
@@ -339,7 +344,14 @@ def set_linewidth(self, w):
339344
ACCEPTS: float or None for default
340345
"""
341346
if w is None:
342-
w = mpl.rcParams['patch.linewidth']
347+
if (not self._fill or
348+
self._edge_default or
349+
mpl.rcParams['_internal.classic_mode']):
350+
w = mpl.rcParams['patch.linewidth']
351+
if w is None:
352+
w = mpl.rcParams['axes.linewidth']
353+
else:
354+
w = 0
343355

344356
self._linewidth = float(w)
345357

@@ -848,6 +860,8 @@ class PathPatch(Patch):
848860
"""
849861
A general polycurve path patch.
850862
"""
863+
_edge_default = True
864+
851865
def __str__(self):
852866
return "Poly((%g, %g) ...)" % tuple(self._path.vertices[0])
853867

@@ -2397,6 +2411,8 @@ class FancyBboxPatch(Patch):
23972411
23982412
"""
23992413

2414+
_edge_default = True
2415+
24002416
def __str__(self):
24012417
return self.__class__.__name__ \
24022418
+ "(%g,%g;%gx%g)" % (self._x, self._y,

lib/matplotlib/rcsetup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ def validate_hist_bins(s):
813813
'lines.linestyle': ['-', six.text_type], # solid line
814814
'lines.color': ['b', validate_color], # blue
815815
'lines.marker': ['None', six.text_type], # black
816-
'lines.markeredgewidth': [0.5, validate_float],
816+
'lines.markeredgewidth': [1.0, validate_float],
817817
'lines.markersize': [6, validate_float], # markersize, in points
818818
'lines.antialiased': [True, validate_bool], # antialiased (no jaggies)
819819
'lines.dash_joinstyle': ['round', validate_joinstyle],
@@ -825,7 +825,7 @@ def validate_hist_bins(s):
825825
'markers.fillstyle': ['full', validate_fillstyle],
826826

827827
## patch props
828-
'patch.linewidth': [1.0, validate_float], # line width in points
828+
'patch.linewidth': [None, validate_float_or_None], # line width in points
829829
'patch.edgecolor': ['k', validate_color], # black
830830
'patch.facecolor': ['b', validate_color], # blue
831831
'patch.antialiased': [True, validate_bool], # antialiased (no jaggies)
@@ -1035,7 +1035,7 @@ def validate_hist_bins(s):
10351035
'legend.markerscale': [1.0, validate_float],
10361036
'legend.shadow': [False, validate_bool],
10371037
'legend.facecolor': ['inherit', validate_color_or_inherit],
1038-
'legend.edgecolor': ['inherit', validate_color_or_inherit],
1038+
'legend.edgecolor': ['k', validate_color_or_inherit],
10391039

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

matplotlibrc.template

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ backend : %(backend)s
8282
#lines.linestyle : - # solid line
8383
#lines.color : blue # has no affect on plot(); see axes.prop_cycle
8484
#lines.marker : None # the default marker
85-
#lines.markeredgewidth : 0.5 # the line width around the marker symbol
85+
#lines.markeredgewidth : 1.0 # the line width around the marker symbol
8686
#lines.markersize : 6 # markersize, in points
8787
#lines.dash_joinstyle : miter # miter|round|bevel
8888
#lines.dash_capstyle : butt # butt|round|projecting
@@ -97,8 +97,10 @@ backend : %(backend)s
9797
# circles. See
9898
# http://matplotlib.org/api/artist_api.html#module-matplotlib.patches
9999
# information on patch properties
100-
#patch.linewidth : 1.0 # edge width in points
101-
#patch.facecolor : blue
100+
#patch.linewidth : None # edge width in points.
101+
# If None, use axes.linewidth when patch
102+
# is not filled.
103+
#patch.facecolor : b
102104
#patch.edgecolor : black
103105
#patch.antialiased : True # render patches in antialiased (no jaggies)
104106

@@ -377,6 +379,8 @@ backend : %(backend)s
377379
#legend.frameon : True # whether or not to draw a frame around legend
378380
#legend.framealpha : None # opacity of of legend frame
379381
#legend.scatterpoints : 3 # number of scatter points
382+
#legend.facecolor : inherit
383+
#legend.edgecolor : k
380384

381385
### FIGURE
382386
# See http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure

0 commit comments

Comments
 (0)