Trying to place subtitles next to each other

I am trying to place two subtitles next to each other (as opposed to each other). I expect to see [sp1] [sp2]
Instead, only the second graph [sp2] is displayed.

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()

Regards,
Axel

+3
source share
2 answers

3 numbers are rows, columns and graph #. What you do determines the number of columns in your second subheading call, which in turn changes the configuration and forces you to start working with the gun.

What do you have in mind:

subplot(121)  # 1 row, 2 columns, Plot 1
...
subplot(122)  # 1 row, 2 columns, Plot 2
+7
source
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()
+4
source

Source: https://habr.com/ru/post/1720940/


All Articles