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 27adae6

Browse filesBrowse files
committed
Merge pull request #5596 from mdboom/no-edges-by-default
STY: No edges on filled things by default
1 parent 1e93214 commit 27adae6
Copy full SHA for 27adae6

File tree

11 files changed

+108
-27
lines changed
Filter options

11 files changed

+108
-27
lines changed

‎examples/pylab_examples/fancyarrow_demo.py

Copy file name to clipboardExpand all lines: examples/pylab_examples/fancyarrow_demo.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def to_texstring(s):
2525
for i, (stylename, styleclass) in enumerate(sorted(styles.items())):
2626
x = 3.2 + (i//nrow)*4
2727
y = (figheight - 0.7 - i % nrow) # /figheight
28-
p = mpatches.Circle((x, y), 0.2, fc="w")
28+
p = mpatches.Circle((x, y), 0.2)
2929
ax.add_patch(p)
3030

3131
ax.annotate(to_texstring(stylename), (x, y),
@@ -37,7 +37,7 @@ def to_texstring(s):
3737
patchB=p,
3838
shrinkA=5,
3939
shrinkB=5,
40-
fc="w", ec="k",
40+
fc="k", ec="k",
4141
connectionstyle="arc3,rad=-0.05",
4242
),
4343
bbox=dict(boxstyle="square", fc="w"))

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+19-8Lines changed: 19 additions & 8 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)
@@ -3762,11 +3762,16 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
37623762
If None, defaults to (lines.linewidth,).
37633763
37643764
edgecolors : color or sequence of color, optional, default: None
3765-
If None, defaults to (patch.edgecolor).
3765+
If None, defaults to 'face'
3766+
37663767
If 'face', the edge color will always be the same as
3767-
the face color. If it is 'none', the patch boundary will not
3768-
be drawn. For non-filled markers, the `edgecolors` kwarg
3769-
is ignored; color is determined by `c`.
3768+
the face color.
3769+
3770+
If it is 'none', the patch boundary will not
3771+
be drawn.
3772+
3773+
For non-filled markers, the `edgecolors` kwarg
3774+
is ignored and forced to 'face' internally.
37703775
37713776
Returns
37723777
-------
@@ -3823,6 +3828,9 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
38233828
else:
38243829
c = 'b' # The original default
38253830

3831+
if edgecolors is None and not rcParams['_internal.classic_mode']:
3832+
edgecolors = 'face'
3833+
38263834
self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
38273835
x = self.convert_xunits(x)
38283836
y = self.convert_yunits(y)
@@ -3875,6 +3883,7 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
38753883
marker_obj.get_transform())
38763884
if not marker_obj.is_filled():
38773885
edgecolors = 'face'
3886+
linewidths = rcParams['lines.linewidth']
38783887

38793888
offsets = np.dstack((x, y))
38803889

@@ -4018,9 +4027,9 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
40184027
the alpha value for the patches
40194028
40204029
*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
4030+
If *None*, defaults to 1.0. Note that this is a tuple, and
4031+
if you set the linewidths argument you must set it as a
4032+
sequence of floats, as required by
40244033
:class:`~matplotlib.collections.RegularPolyCollection`.
40254034
40264035
Other keyword arguments controlling the Collection properties:
@@ -4213,6 +4222,8 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
42134222

42144223
if edgecolors == 'none':
42154224
edgecolors = 'face'
4225+
if linewidths is None:
4226+
linewidths = [1.0]
42164227

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

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+1-1Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/collections.py
+17-1Lines 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/lines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/lines.py
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -848,12 +848,12 @@ def get_marker(self):
848848
def get_markeredgecolor(self):
849849
mec = self._markeredgecolor
850850
if (is_string_like(mec) and mec == 'auto'):
851-
if self._marker.get_marker() in ('.', ','):
852-
return self._color
853-
if self._marker.is_filled() and self.get_fillstyle() != 'none':
854-
return 'k' # Bad hard-wired default...
855-
else:
856-
return self._color
851+
if rcParams['_internal.classic_mode']:
852+
if self._marker.get_marker() in ('.', ','):
853+
return self._color
854+
if self._marker.is_filled() and self.get_fillstyle() != 'none':
855+
return 'k' # Bad hard-wired default...
856+
return self._color
857857
else:
858858
return mec
859859

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

Copy file name to clipboardExpand all lines: lib/matplotlib/mpl-data/stylelib/classic.mplstyle
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,3 +497,5 @@ animation.convert_path: convert # Path to ImageMagick's convert binary.
497497
# is also the name of a system tool.
498498
animation.convert_args:
499499
animation.html: none
500+
501+
_internal.classic_mode: True

‎lib/matplotlib/patches.py

Copy file name to clipboardExpand all lines: lib/matplotlib/patches.py
+22-2Lines changed: 22 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

@@ -1120,6 +1134,8 @@ class FancyArrow(Polygon):
11201134
Like Arrow, but lets you set head width and head height independently.
11211135
"""
11221136

1137+
_edge_default = True
1138+
11231139
def __str__(self):
11241140
return "FancyArrow()"
11251141

@@ -2397,6 +2413,8 @@ class FancyBboxPatch(Patch):
23972413
23982414
"""
23992415

2416+
_edge_default = True
2417+
24002418
def __str__(self):
24012419
return self.__class__.__name__ \
24022420
+ "(%g,%g;%gx%g)" % (self._x, self._y,
@@ -2449,6 +2467,7 @@ def __init__(self, xy, width, height,
24492467

24502468
self._mutation_scale = mutation_scale
24512469
self._mutation_aspect = mutation_aspect
2470+
24522471
self.stale = True
24532472

24542473
@docstring.dedent_interpd
@@ -3935,6 +3954,7 @@ class FancyArrowPatch(Patch):
39353954
"""
39363955
A fancy arrow patch. It draws an arrow using the :class:ArrowStyle.
39373956
"""
3957+
_edge_default = True
39383958

39393959
def __str__(self):
39403960

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+11-4Lines changed: 11 additions & 4 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
@@ -1208,7 +1208,14 @@ def validate_hist_bins(s):
12081208
'animation.convert_path': ['convert', six.text_type],
12091209
# Additional arguments for mencoder movie writer (using pipes)
12101210

1211-
'animation.convert_args': [[], validate_stringlist]}
1211+
'animation.convert_args': [[], validate_stringlist],
1212+
1213+
# Classic (pre 2.0) compatibility mode
1214+
# This is used for things that are hard to make backward compatible
1215+
# with a sane rcParam alone. This does *not* turn on classic mode
1216+
# altogether. For that use `matplotlib.style.use('classic')`.
1217+
'_internal.classic_mode': [False, validate_bool]
1218+
}
12121219

12131220

12141221
if __name__ == '__main__':
Loading

‎lib/matplotlib/tests/test_artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_artist.py
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import matplotlib.path as mpath
1313
import matplotlib.transforms as mtrans
1414
import matplotlib.collections as mcollections
15+
import matplotlib as mpl
1516
from matplotlib.testing.decorators import image_comparison, cleanup
1617

1718
from nose.tools import (assert_true, assert_false)
@@ -176,6 +177,26 @@ def test_remove():
176177
assert_true(ax.stale)
177178

178179

180+
@image_comparison(baseline_images=["default_edges"], remove_text=True,
181+
extensions=['png'], style='default')
182+
def test_default_edges():
183+
with mpl.rc_context({'patch.linewidth': None}):
184+
fig, [[ax1, ax2], [ax3, ax4]] = plt.subplots(2, 2)
185+
186+
ax1.plot(np.arange(10), np.arange(10), 'x',
187+
np.arange(10) + 1, np.arange(10), 'o')
188+
ax2.bar(np.arange(10), np.arange(10))
189+
ax3.text(0, 0, "BOX", size=24, bbox=dict(boxstyle='sawtooth'))
190+
ax3.set_xlim((-1, 1))
191+
ax3.set_ylim((-1, 1))
192+
pp1 = mpatches.PathPatch(
193+
mpath.Path([(0, 0), (1, 0), (1, 1), (0, 0)],
194+
[mpath.Path.MOVETO, mpath.Path.CURVE3,
195+
mpath.Path.CURVE3, mpath.Path.CLOSEPOLY]),
196+
fc="none", transform=ax4.transData)
197+
ax4.add_patch(pp1)
198+
199+
179200
if __name__ == '__main__':
180201
import nose
181202
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

‎matplotlibrc.template

Copy file name to clipboardExpand all lines: matplotlibrc.template
+7-3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.