I hope this hasn't been posted before: I should plot the difference in altitude over time with a picture of a mountain. But I should only plot the colormap in a certain area (black line). I get the colormap usind a grid for 2 different years and calculating the difference in altitude.
My result:
plt.imshow(bild1, extent = [-1100,-200, 1500, 2100], cmap = "Greys_r")
plt.imshow(grid_delta, cmap = "jet", vmin = -5, vmax = 17, origin = "lower", extent = [-1100,-200,1500,2100])
plt.colorbar(boundaries = bounds, ticks = bounds)
plt.plot(studienbereich_x, studienbereich_y, "black", label="Studienbereich", linewidth = 2)
plt.xlim(-1100, -200)
plt.ylim(1500, 2100)
plt.savefig("example.png")
This is what I get: https://i.stack.imgur.com/hy5MH.jpg
This is what I should get: https://i.stack.imgur.com/xQdd7.jpg
I also tried figuring out the data points inside the area of need before interpolating the grids but in the end it didn't fit the area very well.
Change your code to following may solve your problem:
Reference: https://matplotlib.org/examples/pylab_examples/colorbar_tick_labelling_demo.html