matplotlib / matplotlib/matplotlib
[MNT]: Confusing edgecolor behavior for Patch and Collection
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 23.2k
- Forks
- 8.5k
- Merge medio
- 1 d 6 h
- PR fusionados (30 d)
- 66
Descripción
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 consequence rcParams["patch.edgecolor"] does not have an effect by default. There are, however two cases when rcParams["patch.edgecolor"] becomes relevant:
- If facecolor is "none", Patch and Collection take
rcParams["patch.edgecolor"]as edgecolor.
I assume, this is done to prevent the artist being completely invisible (no facecolor and no edgecolor). - If
rcParams["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 introduced rcParams["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 new rcParams["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
- If
patch.force_edgecolorwas False:
from:
topatch.edgecolor: COLOR #patch.force_edgecolor: False#patch.edgecolor: "none" patch.edgecolor_fallback: COLOR - If
patch.force_edgecolorwas True:
from:
topatch.edgecolor: COLOR patch.force_edgecolor: Truepatch.edgecolor: COLOR patch.edgecolor_fallback: COLOR
Transition path
patch.force_edgecolorgets deprecated and raises a warning when used on rcParams.- styles that don't use any of
patch.edgecolororpatch.force_edgecolordo not have to do anything. - styles that have set
patch.edgecolorbut notpatch.force_edgecolorare a very edge case. They either have overlooked that the defaultforce_edgecolor=Falsemakes 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).
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
No se nombra ningún archivo fuente ni ninguna prueba. Empieza trazando el manejo de edgecolor de Patch y Collection y las configuraciones de rcParams, matplotlibrc y style descritas en la propuesta; el trabajo está terminado cuando los valores predeterminados propuestos, el comportamiento de fallback, la deprecación de force_edgecolor y las migraciones de style existentes se hayan validado de forma coherente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- data-visualization
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100