#!/usr/bin/env python
# -*- encoding: utf-8 -*-
import sys
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rcParams
rcParams['font.size'] = 18
# Available interpolation methods:
# 'none', 'nearest', 'bilinear', 'bicubic', 'spline16',
# 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser', 'quadric',
# 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc', 'lanczos'
METHODS = [ 'nearest', 'bilinear', 'bicubic', 'hermite' ]
FORMATS = [ 'png', 'pdf', 'svg' ]
COLORS = 'viridis'
N = 5
np.random.seed(1)
grid = np.arange(0, N, 1)
data = np.round(np.random.rand(N, N), 1)
mesh = np.meshgrid(grid, grid)
for interp in METHODS:
fig = plt.figure(figsize=(5,5))
ax = fig.add_axes([0.125, 0.175, 0.75, 0.75])
plt.imshow(data, interpolation=interp, cmap=COLORS, vmin=0, vmax=1)
plt.plot(mesh[0], mesh[1], marker='.', ms=8, color='k', lw=0)
plt.title(interp, weight='bold')
plt.xlim(grid.min()-0.5, grid.max()+0.5)
plt.ylim(grid.min()-0.5, grid.max()+0.5)
plt.xticks(grid)
plt.yticks(grid)
cax = fig.add_axes([0.125, 0.075, 0.75, 0.03])
cb = plt.colorbar(cax=cax, orientation='horizontal',
ticks=np.linspace(0, 1, 6))
cb.solids.set_edgecolor('face')
for ext in FORMATS:
plt.savefig("{}_{}.{}".format(sys.argv[0], interp, ext))