Currently I have 3 plots that I am plotting in the 2x2 subplots. It looks like this:
fig, axes = plt.subplots(nrows=2, ncols=2)
df1.plot('type_of_plot', ax=axes[0, 0]);
df2.plot('type_of_plot', ax=axes[0, 1]);
df3.plot('type_of_plot', ax=axes[1, 0]);
The 4-th subplot is empty, and I would like the 3-rd one to occupy the whole last row.
I tried various combinations of axes for the third subplot. Like axes[1]
, axes[1:]
, axes[1,:]
. But everything results in the error.
So how can I achieve what I want?
You can do this :
import matplotlib.pyplot as plt
fig=plt.figure()
a=fig.add_axes((0.05,0.05,0.4,0.4)) # number here are coordinate (left,bottom,width,height)
b=fig.add_axes((0.05,0.5,0.4,0.4))
c=fig.add_axes((0.5,0.05,0.4,0.85))
df1.plot('type_of_plot', ax=a);
df2.plot('type_of_plot', ax=b);
df3.plot('type_of_plot', ax=c);
plt.show()
see also the documentation of add_axes
The rect
coordinate I gave you are not very readable, but you can easily adjust it.
EDIT: Here is what I got :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With