Skip to content

The linestyle 'None', ' ' and '' not supported by PathPatch. #5519

Closed

Description

@Rezangyal

The linestyle 'None', ' ' and '' not supported by PathPatch.
Line2D support these values, but PathPatch not.

the documentation say, that these are acceptable values:
http://matplotlib.org/api/patches_api.html#matplotlib.patches.PathPatch

from matplotlib import pylab
from matplotlib.patches import PathPatch
from matplotlib.path import Path
pylab.plot([0,1,2], [4,5,6], ls='solid') #ok
pylab.plot([0,1,2], [3,4,5], ls='-') #ok
pylab.plot([0,1,2], [3,5,7], ls='None') #ok
pylab.gca().add_patch(PathPatch(Path([(3,0), (2,1)]), fill=False, ls='-')) #ok
pylab.gca().add_patch(PathPatch(Path([(3,1), (2,2)]), fill=False, ls='solid')) #ok
pylab.gca().add_patch(PathPatch(Path([(3,2), (2,3)]), fill=False, ls='None')) # !!! ERROR
pylab.show()

the exact error message:
File "...\site-packages\matplotlib\backend_bases.py", line 1064, in set_linestyle
raise ValueError('Unrecognized linestyle: %s' % str(style))
ValueError: Unrecognized linestyle: None

version: matplotlib 1.5.0

Activity

  1. WeatherGod commented on Nov 19, 2015

    @WeatherGod
    Member

    I am betting that this is not a regression, but rather a crack in the API
    when we attempted to merge the notations for linestyles for v1.5.

    On Thu, Nov 19, 2015 at 2:34 PM, Rezangyal notifications@github.com wrote:

    The linestyle 'None', ' ' and '' not supported by PathPatch.
    Line2D support these values, but PathPatch not.

    the documentation say, that these are acceptable values:
    http://matplotlib.org/api/patches_api.html#matplotlib.patches.PathPatch

    from matplotlib import pylabfrom matplotlib.patches import PathPatchfrom matplotlib.path import Path
    pylab.plot([0,1,2], [4,5,6], ls='solid') #ok
    pylab.plot([0,1,2], [3,4,5], ls='-') #ok
    pylab.plot([0,1,2], [3,5,7], ls='None') #ok
    pylab.gca().add_patch(PathPatch(Path([(3,0), (2,1)]), fill=False, ls='-')) #ok
    pylab.gca().add_patch(PathPatch(Path([(3,1), (2,2)]), fill=False, ls='solid')) #ok
    pylab.gca().add_patch(PathPatch(Path([(3,2), (2,3)]), fill=False, ls='None')) # !!! ERROR
    pylab.show()

    the exact error message:
    File "...\site-packages\matplotlib\backend_bases.py", line 1064, in
    set_linestyle
    raise ValueError('Unrecognized linestyle: %s' % str(style))
    ValueError: Unrecognized linestyle: None

    version: matplotlib 1.5.0

    —
    Reply to this email directly or view it on GitHub
    #5519.

  2. Rezangyal commented on Nov 19, 2015

    @Rezangyal
    ContributorAuthor

    as i see the these values handled in Line2D.draw() in the "if funcname != '_draw_nothing'" condition,
    but in Patch.draw() no such functionality.

    I think the solution in the Patch.draw():

    ....
    if self._edgecolor[3] == 0 or self._linestyle in {'none', 'None', ' ', ''}:
                lw = 0
    else:
                gc.set_linestyle(self._linestyle)
    .....
  3. added this to the milestone on Nov 20, 2015
  4. WeatherGod commented on Nov 20, 2015

    @WeatherGod
    Member

    Would you like to put together a PR with that proposed fix?

    On Thu, Nov 19, 2015 at 3:20 PM, Rezangyal notifications@github.com wrote:

    as i see the these values handled in Line2D.draw() in the "if funcname !=
    '_draw_nothing'" condition,
    but in Patch.draw() no such functionality.

    I think the solution in the Patch.draw():

    ....if self._edgecolor[3] == 0 or self._linestyle in {'none', 'None', ' ', ''}:
    lw = 0else:
    gc.set_linestyle(self._linestyle)
    .....

    —
    Reply to this email directly or view it on GitHub
    #5519 (comment)
    .

  5. phobson commented on Jan 24, 2017

    @phobson
    Member

    I think this can be closed per #5696

  6. QuLogic commented on Jan 24, 2017

    @QuLogic
    Member

    That PR is closed, not merged; is there a replacement?

  7. phobson commented on Jan 24, 2017

    @phobson
    Member

    @QuLogic. You're right, I got lost in the maze of references.

  8. modified the milestones: , on May 3, 2017
  9. modified the milestones: , on Oct 9, 2017
  10. modified the milestones: needs sorting, v3.4.0 on Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions