Bitwise anwer に基づいて、次の関数を使用できます。
def pcolormesh_45deg(C, ax=None, xticks=None, xticklabels=None, yticks=None,
yticklabels=None, aspect='equal', rotation=45,
*args, **kwargs):
import itertools
if ax is None:
ax = plt.gca()
n = C.shape[0]
# create rotation/scaling matrix
t = np.array([[1, .5], [-1, .5]])
# create coordinate matrix and transform it
product = itertools.product(range(n, -1, -1), range(0, n + 1, 1))
A = np.dot(np.array([(ii[1], ii[0]) for ii in product]), t)
# plot
ax.pcolormesh((2 * A[:, 1].reshape(n + 1, n + 1) - n),
A[:, 0].reshape(n + 1, n + 1),
np.flipud(C), *args, **kwargs)
xticks = np.linspace(0, n - 1, n, dtype=int) if xticks is None else xticks
yticks = np.linspace(0, n - 1, n, dtype=int) if yticks is None else yticks
if xticks is not None:
xticklabels = xticks if xticklabels is None else xticklabels
for tick, label, in zip(xticks, xticklabels):
ax.scatter(-n + tick + .5, tick + .5, marker='x', color='k')
ax.text(-n + tick + .5, tick + .5, label,
horizontalalignment='right', rotation=-rotation)
if yticks is not None:
yticklabels = yticks if yticklabels is None else yticklabels
for tick, label, in zip(yticks, yticklabels):
ax.scatter(tick + .5, n - tick - .5, marker='x', color='k')
ax.text(tick + .5, n - tick - .5, label,
horizontalalignment='left', rotation=rotation)
if aspect:
ax.set_aspect(aspect)
ax.set_xlim(-n, n)
ax.set_ylim(-n, n)
ax.plot([-n, 0, n, 0., -n], [0, n, 0, -n, 0], color='k')
ax.axis('off')
return ax