In [1]:
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt

In [60]:
n = 400
og = np.full(shape=(n,n), fill_value=0)

In [61]:
import random

for i in range(n**2 /10):
    row = random.randint(0,n-1)
    col = random.randint(0,n-1)
    og[row,col] = 1

In [62]:
for j in range(n):
    for i in range(n):
        if og[i,j] > 0:
            exp = og[i, j]+1
            if i < n-1 and og[i+1,j] == 0:
                og[i+1, j] = exp 
            if j < n-1 and og[i, j+1] == 0:
                og[i, j+1] = exp
            if i > 0 and og[i-1, j] == 0:
                og[i-1, j] = exp
            if j > 0 and og[i, j-1] == 0:
                og[i, j-1] = exp

In [63]:
%matplotlib inline 
plt.figure(figsize=(12,12))
ax = plt.subplot(111)
sns.heatmap(og, ax=ax, square=True, linewidths=0, xticklabels=[0,n], yticklabels=[0,n])


Out[63]:
<matplotlib.axes._subplots.AxesSubplot at 0x11e0dce50>

In [ ]: