Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[MNT]: Confusing edgecolor behavior for Patch and Collection #29261

Open
@timhoffm

Description

@timhoffm

Noted while reviewing documentation on the current behavoir in#29252.

Summary

Patches and Collections do not draw edges by default. This was introduced in#5596 for matplotlib 2.0. It seems that this was first achieved by a linewidth 0, but it this was changed to using an edgecolor of "none" while maintaining a finite linewidth.

As a consequencercParams["patch.edgecolor"] does not have an effect by default. There are, however two cases whenrcParams["patch.edgecolor"] becomes relevant:

  1. If facecolor is "none", Patch and Collection takercParams["patch.edgecolor"] as edgecolor.
    I assume, this is done to prevent the artist being completely invisible (no facecolor and no edgecolor).
  2. IfrcParams["patch.force_edgecolor"] is set to true,rcParams["patch.edgecolor"] is used instead of "none" as the

This is overall very confusing.

Ping@efiring, who introducedrcParams["patch.force_edgecolor"] in#6904. Can you comment on the background and whether the proposal below is a reasonable alternative?

Proposed fix

Can we switch to the following logic:patch.edgecolor is generally used as edgecolor and now defaults to "none" (to achieve the same behavior as before). To handle case 1. (prevent invisible artists) introduce a newrcParams["patch.edgecolor_fallback"] that has a special color only for that case.

Needed changes to default rcParams

matplotlibrc before:

#patch.edgecolor: black#patch.force_edgecolor: False

matplotlibrc after

#patch.edgecolor: "none"            # default edgecolor for Patch and Collection#patch.edgecolor_fallback: "black"  # edgecolor to be used if facecolor is "none" to prevent completely invisible artists

Needed changes to styles

Existing styles would migrate

  • Ifpatch.force_edgecolor was False:
    from:
    patch.edgecolor: COLOR#patch.force_edgecolor: False
    to
    #patch.edgecolor: "none"patch.edgecolor_fallback:  COLOR
  • Ifpatch.force_edgecolor was True:
    from:
    patch.edgecolor: COLORpatch.force_edgecolor: True
    to
    patch.edgecolor: COLORpatch.edgecolor_fallback:  COLOR

Transition path

  • patch.force_edgecolor gets deprecated and raises a warning when used on rcParams.
  • styles that don't use any ofpatch.edgecolor orpatch.force_edgecolor do not have to do anything.
  • styles that have setpatch.edgecolor but notpatch.force_edgecolor are a very edge case. They either have overlooked that the defaultforce_edgecolor=False makes the setting ineffective, or they have intentionally only configured the somewhat arcane edge color fallback for non-filled artists. In the former case, they get "auto-fixed" through the new behavior. I'd argue that we can affort to not runtime-warn on the latter case (but if really wanted, one could add a check at least for loading stylesheets).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp