Allow to use a non fixed axes formatter
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 52/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- python
- Área
- data-visualization
Línea de trabajo
Empieza leyendo el formatter fijo en plotnine/_mpl/ticker.py y cómo se aplica desde plotnine/facets/facet.py. Traza el flujo de dibujo de ggplot y la interacción entre plot.draw(), plot.show() y los ejes expuestos por la figure. El resultado debe permitir a los usuarios aplicar locators y formatters de Matplotlib, como AutoLocator y EngFormatter, para que los ticks se actualicen adecuadamente al hacer zoom, sin monkey-patching de ggplot.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hello,
I am a Python user that came from using plain Matplotlib (not an R user switching to Python). I noticed today that if I take e.g this plot:
And zoom in:
The x & y ticks are fixed! I tried to figure out from reading the code whether I can change this, and I encountered this in plotnine's code:
Which is used here:
I am not sure whether the graphics grammar allows modifying this behavior, but I won't mind doing it via Matplotlib's native functions. However, that turned out to be hard and frustrating, as plot.draw() returns a figure, but I can't modify the axes of it. Here's something I tried:
from matplotlib.ticker import (
EngFormatter,
AutoLocator,
)
for ax in plot.draw(show=False).axes:
ax.xaxis.set_major_locator(AutoLocator())
ax.yaxis.set_major_locator(AutoLocator())
ax.xaxis.set_major_formatter(EngFormatter())
ax.yaxis.set_major_formatter(EngFormatter())
plot.show() # Also tried `matplotlib.pyplot.show()` here too.
And it doesn't show anything. As a side note, this made me wonder: What is the benefit in returning the figure if it cannot be manipulated afterwards with plain-old Matplotlib? This is related of course to:
Anyway, I managed to workaround this with the following ugly monkey-patching of ggplot class:
from matplotlib.ticker import (
EngFormatter,
AutoLocator,
)
ggplot_original__draw_breaks_and_labels = ggplot._draw_breaks_and_labels
def ggplot__draw_breaks_and_labels_with_my_ax_manipulation(self):
ggplot_original__draw_breaks_and_labels(self)
for ax in self.axs:
ax.xaxis.set_major_formatter(EngFormatter(unit="Hz"))
ax.yaxis.set_major_formatter(EngFormatter(unit="Hz"))
ax.xaxis.set_major_locator(AutoLocator())
ax.yaxis.set_major_locator(AutoLocator())
ggplot._draw_breaks_and_labels = ggplot__draw_breaks_and_labels_with_my_ax_manipulation
Not sure why the ticks are located in fixed positions just due to the major_formatter set above, but for sure the AutoLocator is needed too.
- Lenguaje dominante
- Python
- Estrellas
- 4.8k
- Forks
- 260
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 4
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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.
Más de has2k1/plotnine
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Enhancement
Dificultad 3/5 Medio día Aptitud para principiantes 55/100
has2k1/plotnine#1141 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Discussion
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
has2k1/plotnine#1047 · 15 comentarios · 3 reacciones ·
Los mantenedores suelen responder en 1 día
-
Documentation Plot Composition Question
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
has2k1/plotnine#1036 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
plotnine 0.16.0 alpha releasesAbiertoInstallation Plot Composition
Dificultad 1/5 Menos de una hora Aptitud para principiantes 20/100
has2k1/plotnine#1031 · 11 reacciones ·
Los mantenedores suelen responder en 1 día
Todos los issues de has2k1/plotnine
Issues similares
-
bug triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
mealie-recipes/mealie#9117 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
freelawproject/courtlistener#8406 ·
Los mantenedores suelen responder en 2 días
-
good first issue help wanted level 1 wocs
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
GianlucaBave/murmury#49 ·
Los mantenedores suelen responder en 1 día
-
regression skipped skipped_bmg
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
intel/torch-xpu-ops#6142 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
good first issue help wanted python up-for-grabs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
andrewsiah/agentswarm-data-tasks#122 ·
Los mantenedores suelen responder en 1 día