Skip to content

Commit 42f09b6

Browse files
committed
Merge pull request #3602 from nkoep/markers-fillstyle-rcparams
Add rcParams support for markers' fillstyle prop
2 parents 28ccfa9 + d0d9fa3 commit 42f09b6

File tree

7 files changed

+35
-8
lines changed

7 files changed

+35
-8
lines changed

doc/users/whats_new/rcparams.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ multiple images on a set of axes into a single composite image. Saving each
3737
image individually can be useful if you generate vector graphics files in
3838
matplotlib and then edit the files further in Inkscape or other programs.
3939

40+
Added ``markers.fillstyle`` key to rcParams
41+
```````````````````````````````````````````
42+
Controls the default fillstyle of markers. Possible values are ``'full'`` (the
43+
default), ``'left'``, ``'right'``, ``'bottom'``, ``'top'`` and ``'none'``.
4044

4145
Added "toolmanager" to "toolbar" possible values
4246
````````````````````````````````````````````````

lib/matplotlib/lines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def __init__(self, xdata, ydata,
256256
markeredgecolor=None,
257257
markerfacecolor=None,
258258
markerfacecoloralt='none',
259-
fillstyle='full',
259+
fillstyle=None,
260260
antialiased=None,
261261
dash_capstyle=None,
262262
solid_capstyle=None,

lib/matplotlib/markers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class MarkerStyle(object):
145145
# TODO: Is this ever used as a non-constant?
146146
_point_size_reduction = 0.5
147147

148-
def __init__(self, marker=None, fillstyle='full'):
148+
def __init__(self, marker=None, fillstyle=None):
149149
"""
150150
MarkerStyle
151151
@@ -165,6 +165,8 @@ def __init__(self, marker=None, fillstyle='full'):
165165
fillstyle : string, optional, default: 'full'
166166
'full', 'left", 'right', 'bottom', 'top', 'none'
167167
"""
168+
# The fillstyle has to be set here as it might be accessed by calls to
169+
# _recache() in set_marker.
168170
self._fillstyle = fillstyle
169171
self.set_marker(marker)
170172
self.set_fillstyle(fillstyle)
@@ -211,6 +213,8 @@ def set_fillstyle(self, fillstyle):
211213
----------
212214
fillstyle : string amongst known fillstyles
213215
"""
216+
if fillstyle is None:
217+
fillstyle = rcParams['markers.fillstyle']
214218
if fillstyle not in self.fillstyles:
215219
raise ValueError("Unrecognized fillstyle %s"
216220
% ' '.join(self.fillstyles))

lib/matplotlib/rcsetup.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ def validate_ps_distiller(s):
392392
['butt', 'round', 'projecting'],
393393
ignorecase=True)
394394

395+
validate_fillstyle = ValidateInStrings('markers.fillstyle',
396+
['full', 'left', 'right', 'bottom',
397+
'top', 'none'])
398+
395399
validate_negative_linestyle = ValidateInStrings('negative_linestyle',
396400
['solid', 'dashed'],
397401
ignorecase=True)
@@ -552,6 +556,9 @@ def __call__(self, s):
552556
'lines.dash_capstyle': ['butt', validate_capstyle],
553557
'lines.solid_capstyle': ['projecting', validate_capstyle],
554558

559+
# marker props
560+
'markers.fillstyle': ['full', validate_fillstyle],
561+
555562
## patch props
556563
'patch.linewidth': [1.0, validate_float], # line width in points
557564
'patch.edgecolor': ['k', validate_color], # black

lib/matplotlib/tests/test_axes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2366,6 +2366,16 @@ def test_marker_styles():
23662366
markersize=10+y/5, label=marker)
23672367

23682368

2369+
@image_comparison(baseline_images=['rc_markerfill'], extensions=['png'])
2370+
def test_markers_fillstyle_rcparams():
2371+
fig, ax = plt.subplots()
2372+
x = np.arange(7)
2373+
for idx, (style, marker) in enumerate(
2374+
[('top', 's'), ('bottom', 'o'), ('none', '^')]):
2375+
matplotlib.rcParams['markers.fillstyle'] = style
2376+
ax.plot(x+idx, marker=marker)
2377+
2378+
23692379
@image_comparison(baseline_images=['vertex_markers'], extensions=['png'],
23702380
remove_text=True)
23712381
def test_vertex_markers():

matplotlibrc.template

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ backend : %(backend)s
9090
#lines.solid_capstyle : projecting # butt|round|projecting
9191
#lines.antialiased : True # render lines in antialised (no jaggies)
9292

93+
#markers.fillstyle: full # full|left|right|bottom|top|none
94+
9395
### PATCHES
9496
# Patches are graphical objects that fill 2D space, like polygons or
9597
# circles. See
@@ -256,10 +258,10 @@ backend : %(backend)s
256258
# separator in the fr_FR locale.
257259
#axes.formatter.use_mathtext : False # When True, use mathtext for scientific
258260
# notation.
259-
#axes.formatter.useoffset : True # If True, the tick label formatter
260-
# will default to labeling ticks relative
261-
# to an offset when the data range is very
262-
# small compared to the minimum absolute
261+
#axes.formatter.useoffset : True # If True, the tick label formatter
262+
# will default to labeling ticks relative
263+
# to an offset when the data range is very
264+
# small compared to the minimum absolute
263265
# value of the data.
264266

265267
#axes.unicode_minus : True # use unicode for the minus symbol
@@ -410,7 +412,7 @@ backend : %(backend)s
410412
#savefig.jpeg_quality: 95 # when a jpeg is saved, the default quality parameter.
411413
#savefig.directory : ~ # default directory in savefig dialog box,
412414
# leave empty to always use current working directory
413-
#savefig.transparent : False # setting that controls whether figures are saved with a
415+
#savefig.transparent : False # setting that controls whether figures are saved with a
414416
# transparent background by default
415417

416418
# tk backend params
@@ -500,5 +502,5 @@ backend : %(backend)s
500502
# $PATH is searched
501503
#animation.mencoder_args: '' # Additional arguments to pass to mencoder
502504
#animation.convert_path: 'convert' # Path to ImageMagick's convert binary.
503-
# On Windows use the full path since convert
505+
# On Windows use the full path since convert
504506
# is also the name of a system tool.

0 commit comments

Comments
 (0)