Overlapping pyplot.imshow() plot in single grid

I want to plot this figures. For the first figure:

Figure1.png

For the code snippet:

import matplotlib.pyplot as plt
row = 30
col = row
areas_pher = [[-0.01 for i in range(col)] for j in range(row)] 

for i in range(1, row-1):
    for j in range(1, col-1):
         areas_pher[i][j] = 0
max_pher = 20
for pher in range(1, col-1):
    areas_pher[15][pher] = max_pher * pher/max_pher
plt.imshow(areas_pher, cmap="Blues_r", vmin=0, vmax=max_pher)

And the second figure:

Figure2.png

For the code snippets:

import matplotlib.pyplot as plt
import numpy as np

areas_ant = [[6 for i in range(col)] for j in range(row)]
prob_ant = 0.05    

for i in range(1, row-1):
    for j in range(1, col-1):
        rand = np.random.rand()
        if rand < prob_ant:
            areas_ant[i][j] = 5
plt.imshow(areas_ant, cmap="Blues")

My question, what the best way to make its figures overlapping, for illustrate like this image below?

Overlapping Figures Illustration.png



Read more here: https://stackoverflow.com/questions/64949451/overlapping-pyplot-imshow-plot-in-single-grid

Content Attribution

This content was originally published by Muhammad Alif at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: