2

I have 3 plots arranged vertically with the following code:

plt.figure(1)
plt.subplot(311)
plt.plot(z2, 'blue')
plt.plot(mid2, 'orange')
plt.plot(z3, 'red')
plt.plot(mid3, 'orange')
plt.subplot(312)
plt.plot(z)
plt.plot(mid)
plt.subplot(313)
plt.plot(proportional, "black")

But what I want to do is adding another plot next to the first plot(311). I mean I want to have two plots inside the first row, then one plot inside next two rows as before(I like to show z2,mid2 in one plot and z3,mid3 in other plot next to that, both inside the first row). If is it possible, how can I do that?

Hasani
  • 3,543
  • 14
  • 65
  • 125

1 Answers1

1

I will make another example. This code plt.subplot(324) will make your figure become a 3x2 table (3 rows and 2 columns) and make a coordinate on the "cell 4". See the image belowthe "table" So, if you want to plot z2 and mid2 on "cell 1", then plt.subplot(321) and plot them.

You may want to plot z and mid on both the "cell 3" and "cell 4", then

plt.subplot(312)

(a 3x1 table and make a coordinate on "cell 2", which is equivalent to a 3x2 table with a coordinate on both "cell 3" and "cell 4")

So your code might be something like:

plt.figure(1)

plt.subplot(321)             # "cell 1"
plt.plot(z2, 'blue')
plt.plot(mid2, 'orange')

plt.subplot(322)             # "cell 2"
plt.plot(z3, 'red')
plt.plot(mid3, 'orange')

plt.subplot(312)             # "cell 3" and "cell 4"
plt.plot(z)
plt.plot(mid)

plt.subplot(313)             # "cell 5" and "cell 6"
plt.plot(proportional, "black")
AcaNg
  • 704
  • 1
  • 9
  • 26
  • Thank you very much. Just one question. In row one that I have 2 plots, the labels of right side plot will overlap on the left side plot. Is there a way to make more distance between these to plots or move the labels of the right side plot to it's right side? (By labels I mean the numbers of `Y-AXIS`). – Hasani Jun 19 '19 at 06:15
  • 1
    you can find the answer here: [How to create space between subplots?](https://stackoverflow.com/questions/41030061/how-to-create-space-between-subplots) or [Improve subplot size/spacing with many subplots in matplotlib](https://stackoverflow.com/questions/6541123/improve-subplot-size-spacing-with-many-subplots-in-matplotlib) – AcaNg Jun 19 '19 at 06:19