Last active
May 7, 2024 17:24
-
-
Save alisterburt/d48142744fca6a696bc9a33f782ad18c to your computer and use it in GitHub Desktop.
matplotlib gradient overlays - gradient resolution is different from image resolution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
from cmap import Colormap | |
h, w = 512, 868 | |
image = np.random.random(size=(h, w)) | |
defocus = np.array([[0, 1], | |
[1, 0]]) | |
fig, ax = plt.subplots() | |
ax.imshow(image, cmap='gray') | |
cm = Colormap('tol:BuRd').to_mpl() | |
ax.imshow(defocus, extent=(-0.5, w-0.5, h-0.5, -0.5), alpha=0.3, interpolation='spline36', cmap=cm) | |
plt.show() |
Author
alisterburt
commented
May 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment