Der Versuch, Position Nebenhandlungen nebeneinander
-
06-07-2019 - |
Frage
nebeneinander
Ich versuche, zwei Handlungsstränge zu positionieren (im Gegensatz untereinander zu). Ich erwarte [sp1] sehen [sp2]
Stattdessen wird nur die zweite Handlung [sp2] angezeigt bekommen.
from matplotlib import pyplot
x = [0, 1, 2]
pyplot.figure()
# sp1
pyplot.subplot(211)
pyplot.bar(x, x)
# sp2
pyplot.subplot(221)
pyplot.plot(x, x)
pyplot.show()
Grüße, Axel
Lösung
Die drei Zahlen sind Zeilen, Spalten und Plot #. Was Sie tun, ist die Anzahl der Spalten in Ihrem zweiten Anruf respecifying Nebenhandlung, was wiederum die Konfiguration ändert und verursacht pyplot über zu starten.
Was Sie meinen, ist:
subplot(121) # 1 row, 2 columns, Plot 1
...
subplot(122) # 1 row, 2 columns, Plot 2
Andere Tipps
from matplotlib import pyplot
x = [0, 1, 2]
pyplot.figure()
# sp1
pyplot.subplot(121)
pyplot.bar(x, x)
# sp2
pyplot.subplot(122)
pyplot.plot(x, x)
pyplot.show()
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow