I'm trying to make a "heatmap" with Matplotlib of a 2d Numpy Array and found the NonUniformImage option here. Below is a simple single version. Unfortunately I'm not able to change the x without changing the y. The error that pyhton Propmpts is: Axes don't match array shape
Reproducible Example
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.image import NonUniformImage
from matplotlib import cm
x = np.arange(6)
y = np.arange(6)
z = x[:, np.newaxis].dot(y[:, np.newaxis].transpose())
fig, ax = plt.subplots()
im = NonUniformImage(ax, interpolation='nearest', extent=(0, len(x)-1, 0, len(y)-1))
im.set_data(x, y, z)
ax.images.append(im)
ax.set_xlim(0, len(x)-1)
ax.set_ylim(0, len(y)-1)
My goal is to plot a map based on a Numpy 2d array with 'custom Grid cells'. That means that I can assign x and y with irregular series (e.g. np.array([0.5,3,8,15,15.4]). I know the x and y that are assign represent the center of a cell so the last thing I would like to solve is that the plot is completely visible (if that is possible).
How can I make a image that has a different constraint (not square), with custom width and height depending on two lists?