Circular mask for an array


In [2]:
import numpy as np

In [3]:
from xrdtools import parse_data, disk_mask

In [8]:
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
%matplotlib inline

In [13]:
m = parse_data('../data/result_slice01.txt', colnum=1)
mat = m.values
mask = disk_mask(mat, 27, 27, 20)
mat[~mask] = np.nan

In [15]:
plt.figure(figsize=(10, 10))
plt.pcolor(mat)

ax = plt.gca()
ax.set_aspect('equal')

divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.2)
plt.colorbar(cax=cax)


Out[15]:
<matplotlib.colorbar.Colorbar at 0x7f679e685240>

In [ ]: