
Norm = (vmin=c_min, vmax=c_max)įor c_vals in [c_grid, # values at face cornersĪx = fig.add_subplot(111, projection='3d')

# values at face corners (at the grid points)Ĭ_grid = np.abs(x_grid + y_grid) # same size like x_val, y_val, z_valĬ_faces = np.lib.stride_tricks.sliding_window_view(c_grid, (2,2))Ĭ_faces = np.mean(c_faces, axis=(2, 3)) # size reduces by 1Ĭ_min, c_max = np.min(c_grid), np.max(c_grid) # could also be min and max of c_faces X_grid, y_grid = np.meshgrid(x_lst, y_lst) Here is an example for comparison: import matplotlib as mpl Likewise, it would be possible to linearly interpolate the intermediate values and plot more faces.

You could either calculate new values in the middle of the faces or average the values at the face corners, which is what I needed for measured values. This becomes obvious for a few symetric values (see example below). The facecolors should be one column and row smaller than the grid values! Otherwise, the faces will be colorized shifted according to one value in the face corner (may not matter for many values). I find the previous answers somewhat misleading.
