Search code examples
pythonmatplotlibaxes

Fit the figure size after removing an axe - Matplotlib


I got a figure with 3 axes : I did this :

fig.axes[1].remove()

So I removed the middle axe, but I would like that my left axis fill that is now empty (the white gap between the "map" plot and the colorbar see the image below)

How Can I do this ? (Here is my whole code) :

fig, ax = plt.subplots(figsize=(15,10))
df_plot[df_plot['Risk_add_sin']==0].plot.scatter(x='x_rd', y='y_rd', c='Risk_add_sin', cmap=cmapm, ax=ax)
df_plot[df_plot['Risk_add_sin']!=0].plot.scatter(x='x_rd', y='y_rd', c='Risk_add_sin', cmap=cmapm, ax=ax) 
fig.axes[1].remove()

Thanks, enter image description here


Solution

  • I think this is the wrong question.

    I believe you should pass colorbar=False to one of your df.plot.scatter() call to prevent the creation of one of the colorbar