dkogan / dkogan/gnuplotlib

Multiplot fails if it is the first plot in the script

Offen
#30 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
274
Forks
17
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die beiden Python-Reproduktionen aus dem Issue auszuführen, und verfolge die Verarbeitung von Plot und Multiplot im Projekt. Vergleiche den Fall mit dem ersten Plot mit dem Fall, dem ein Dummy-Plot und _wait=True vorausgehen. Erledigt ist die Aufgabe, wenn ein Skript, dessen erster Plot multiplot="layout 2,1" verwendet, beide Plots rendert, ohne einen Dummy-Plot zu benötigen oder den ersten stillschweigend zu überschreiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
numpy, python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.