FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: gapcolor not supported for LineCollections · Issue #24796 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: gapcolor not supported for LineCollections #24796

Closed

Description

Bug summary

LineCollection doesn't have a get_gapcolor or set_gapcolor, so gapcolor doesn't work in plotting methods that return LineCollections (like vlines or hlines).

Code for reproduction

fig, ax = plt.subplots(figsize=(1,1))
ax.vlines([.25, .75], 0, 1, linestyle=':', gapcolor='orange')

Actual outcome

File ~\miniconda3\envs\prop\lib\site-packages\matplotlib\artist.py:1186, in Artist._internal_update(self, kwargs)
-> 1186     return self._update_props(
   1187         kwargs, "{cls.__name__}.set() got an unexpected keyword argument "
   1188         "{prop_name!r}")

AttributeError: LineCollection.set() got an unexpected keyword argument 'gapcolor'

Expected outcome

Additional information

I think the easiest fix is probably add set_color and get_color to LineCollection, modeled on get_color and set_color

def set_color(self, c):
"""
Set the edgecolor(s) of the LineCollection.
Parameters
----------
c : color or list of colors
Single color (all lines have same color), or a
sequence of RGBA tuples; if it is a sequence the lines will
cycle through the sequence.
"""
self.set_edgecolor(c)
set_colors = set_color
def get_color(self):
return self._edgecolors
get_colors = get_color # for compatibility with old versions

Matplotlib Version

3.7.0.dev1121+g509315008c

Activity

  1. rcomer commented on Dec 23, 2022

    Member

    I had a look at this. Although the LineCollection docstring states that it “Represents a sequence of Line2Ds”, it doesn’t seem to use the Line2D object (unless I’m missing something).

    So I think we might need to modify the Collection.draw method in an analogous way to how we did the Line2D.draw method at #23208. Though Collection.draw is more complicated as it’s obviously supporting a much wider range of cases.

    Another possibility might be to modify LineCollection itself so that, if gapgolor is set, we add the inverse paths into LineCollection._paths (and update._edgecolors, ._linestyles with gapcolors and inverse linestyles). This would mean that what you get out of e.g. .get_colors would be longer than what was put into .set_colors, which might not be desirable.

    Anyway, for now I just mark this as “medium difficulty”, as I do not think it is a task for a beginner.

  2. added
    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Dec 23, 2022
  3. added
    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …
    on Dec 31, 2022
  4. removed
    🌱 Good first issueOpen a pull request against these issues if there are no active ones!
    on Jan 1, 2023
  5. added this to the v3.8.0 milestone on Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL