Как использовать цифры, хранящиеся в переменных, в качестве вспомогательных участков в matplotlib? - PullRequest
0 голосов
/ 11 апреля 2019

Предположим, что набор из 4 matplotlib цифр хранится в переменных fig1 до fig4 .

import matplotlib.pyplot as plt

fig1 = plt.figure()
plt.plot([1, 2, 3, 4])

fig2 = plt.figure()
plt.plot([2, 2, 2, 2])

fig3 = plt.figure()
plt.plot([1, 3, 1, 4])

fig4 = plt.figure()
plt.plot([4, 3, 2, 1])

# code to create subplots using the fig1 to fig4 variables
# i.e. without recreating the original 4 plots

Использование matplotlib (или, возможно, другогопакет), как можно создать фигуру вспомогательных участков (например, в приведенном ниже примере), причем вложенные участки составляют от fig1 до fig4 ?

enter image description here

1 Ответ

0 голосов
/ 11 апреля 2019
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(10,10))
#Set First Axis
ax1 = fig.add_subplot(121)
ax1.plot([1, 3, 1, 4])


#Set Second Axis
ax2 = fig.add_subplot(122)
ax2.plot([2, 2, 2, 2])

ax3 = fig.add_subplot(221)
ax3.plot([1, 3, 1, 4])

ax4 = fig.add_subplot(222)
ax4.plot([4, 3, 2, 1])

enter image description here

...