Skip to content
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
8 changes: 7 additions & 1 deletion lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ def set_linestyle(self, ls):
``'--'`` or ``'dashed'`` dashed line
``'-.'`` or ``'dashdot'`` dash-dotted line
``':'`` or ``'dotted'`` dotted line
``'None'`` draw nothing
``'none'`` draw nothing
``' '`` draw nothing
``''`` draw nothing
=========================== =================

Alternatively a dash tuple of the following form can be provided::
Expand All @@ -424,6 +428,8 @@ def set_linestyle(self, ls):
"""
if ls is None:
ls = "solid"
if ls in [' ', '', 'none']:
ls = 'None'
self._linestyle = ls
# get the unscaled dash pattern
offset, ls = self._us_dashes = mlines._get_dash_pattern(ls)
Expand Down Expand Up @@ -540,7 +546,7 @@ def _bind_draw_path_function(self, renderer):
gc.set_foreground(self._edgecolor, isRGBA=True)

lw = self._linewidth
if self._edgecolor[3] == 0:
if self._edgecolor[3] == 0 or self._linestyle == 'None':
lw = 0
gc.set_linewidth(lw)
gc.set_dashes(self._dashoffset, self._dashes)
Expand Down
26 changes: 26 additions & 0 deletions lib/matplotlib/tests/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,32 @@ def test_patch_linestyle_accents():
fig.canvas.draw()


@check_figures_equal(extensions=['png'])
def test_patch_linestyle_none(fig_test, fig_ref):
circle = mpath.Path.unit_circle()

ax_test = fig_test.add_subplot()
ax_ref = fig_ref.add_subplot()
for i, ls in enumerate(['none', 'None', ' ', '']):
path = mpath.Path(circle.vertices + i, circle.codes)
patch = mpatches.PathPatch(path,
linewidth=3, linestyle=ls,
facecolor=(1, 0, 0),
edgecolor=(0, 0, 1))
ax_test.add_patch(patch)

patch = mpatches.PathPatch(path,
linewidth=3, linestyle='-',
facecolor=(1, 0, 0),
edgecolor='none')
ax_ref.add_patch(patch)

ax_test.set_xlim([-1, i + 1])
ax_test.set_ylim([-1, i + 1])
ax_ref.set_xlim([-1, i + 1])
ax_ref.set_ylim([-1, i + 1])


def test_wedge_movement():
param_dict = {'center': ((0, 0), (1, 1), 'set_center'),
'r': (5, 8, 'set_radius'),
Expand Down