dkogan / dkogan/gnuplotlib

Multiplot fails if it is the first plot in the script

Abierto
#30 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
274
Forks
17
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

When a script has a multiplotas it's very first plot, the plot produced it's a regular plot, the second plot overwrites the first one withouth any error indication:

Let's use this small example:

import numpy as np
import gnuplotlib as gp
th = np.linspace(0, 2*np.pi, 100)
x1 = np.cos(th)
y1 = np.sin(th)
x2 = 2*np.cos(th)
y2 = 3*np.sin(th)

gp.plot(
    ((
        x1,
        y1,
        dict(
            legend = "Circle",
            _with = "linespoints dt 4 pt 4",
        )),
     dict(
         title="Circle",
         xlabel="X",
         ylabel="Y",
     )),
    ((
        x2,
        y2,
        dict(
            legend = "Ellipse",
            _with = "linespoints dt 4 pt 4",
        )),
     dict(title="Ellipse",
         xlabel="X",
         ylabel="Y",
     )),
    _wait=True,
    square=True,
    multiplot="layout 2,1"
)

This produces the following output:

multiplot_1

As we see, the Ellipse plot has overwritten the Circle plot, totally ignoring the multiplot argument. No warnings, no errors. Just silently ignores the option.

However, if we add a regular plot before the multiplot:

import numpy as np
import gnuplotlib as gp
th = np.linspace(0, 2*np.pi, 100)
x1 = np.cos(th)
y1 = np.sin(th)
x2 = 2*np.cos(th)
y2 = 3*np.sin(th)
# Dummy plot so multiplot doesn't fail
gp.plot(
    np.sin(th),
    np.cos(th),
    _wait=True,
)

gp.plot(
    ((
        x1,
        y1,
        dict(
            legend = "Circle",
            _with = "linespoints dt 4 pt 4",
        )),
     dict(
         title="Circle",
         xlabel="X",
         ylabel="Y",
     )),
    ((
        x2,
        y2,
        dict(
            legend = "Ellipse",
            _with = "linespoints dt 4 pt 4",
        )),
     dict(title="Ellipse",
         xlabel="X",
         ylabel="Y",
     )),
    _wait=True,
    square=True,
    multiplot="layout 2,1"
)

We get the desired output

multiplot_2

One curious effect is that this only works if _wait=True is provided in the Dummy Plot

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza ejecutando las dos reproducciones en Python del issue y sigue el manejo de los plots y multiplot en el proyecto. Compara el caso del primer plot con el caso precedido por un plot ficticio y _wait=True. El trabajo estará terminado cuando un script cuyo primer plot use multiplot="layout 2,1" renderice ambos plots sin requerir un plot ficticio ni sobrescribir silenciosamente el primero.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
numpy, python
Área
data-visualization
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.