1

I am attempting to plot overlapping vector and raster maps with following code:

fig, axes = plt.subplots(1,3, figsize=(12, 5))
plt.subplots_adjust(left=None, bottom=None, right=1.1, top=None, wspace=None, hspace=None)

norm1 = colors.BoundaryNorm([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 10)
cmap1 = 'jet'
picca_jan.plot(cmap = cmap1, norm = norm1, add_labels=False, add_colorbar = False, ax=axes[0])
sf_picca.geometry.boundary.plot(ax=axes[0], color=None, alpha = 1, edgecolor='black', linewidth = 1.0)
#axes[0,0].get_yaxis().set_visible(False)
axes[0].get_xaxis().set_visible(False)
axes[0].set_title("month = 1", fontsize=20)

im = picca_feb.plot.imshow(ax = axes[1], cmap = cmap1, norm = norm1, add_labels=False, add_colorbar = False)
sf_picca.geometry.boundary.plot(ax=axes[1], color=None, alpha = 1, edgecolor='black', linewidth = 1.0)
axes[1].get_yaxis().set_visible(False)
axes[1].get_xaxis().set_visible(False)
axes[1].set_title("month = 2", fontsize=20)

im = picca_march.plot.imshow(ax = axes[2], cmap = cmap1, norm = norm1, add_colorbar = False, add_labels=False)
sf_picca.geometry.boundary.plot(ax=axes[2], color=None, alpha = 1, edgecolor='black', linewidth = 1.0)
axes[2].get_yaxis().set_visible(False)
axes[2].get_xaxis().set_visible(False)
axes[2].set_title("month = 3", fontsize=20)
plt.tight_layout()

enter image description here

As it can be seen from the image, size of the second and third image doesn't match. If I remove sf_picca shapefile, I get the figures with exactly the same size.

enter image description here

Can someone please explain what's going on?

3
  • How the result change if you swap plotting order of raster and vector? When geometry is plotted, the plot area may be extended by taking a buffer around it.
    – AMA
    Commented Jul 19, 2021 at 20:11
  • Thanks AMA. I changed the plotting order and again weird result. First image is bigger than the second and third.
    – Sher
    Commented Jul 19, 2021 at 23:51
  • Can you share sample data to reproduce the error?
    – AMA
    Commented Jul 20, 2021 at 11:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.