-
-
Save stephengruppetta/505b26b010b635afce26138e344b4ab9 to your computer and use it in GitHub Desktop.
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 | |
image = plt.imread("gardens.jpg") | |
# Create a figure with two subplots using 'subplot_mosaic' | |
# Argument needs to be a 2D array, which is why | |
# there are two sets of square brackets | |
fig, ax = plt.subplot_mosaic( | |
[["Left", "Right"]] | |
) | |
# You can now use a "dictionary-style" indexing | |
# to refer to each subplot | |
ax["Left"].imshow(image) | |
ax["Left"].axis("off") | |
# Extract the red channel from the image | |
image_red = image.copy() | |
image_red[:, :, 1:] = 0 | |
ax["Right"].imshow(image_red) | |
ax["Right"].axis("off") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment