Skip to content

Instantly share code, notes, and snippets.

View davidwebber's full-sized avatar

David Webber davidwebber

View GitHub Profile
@fasiha
fasiha / README.md
Last active July 12, 2021 17:57
How to visualize 2D arrays in Matplotlib/Python (like imagesc in Matlab)

Visualizing rectangular 2D arrays in Python and Matplotlib the way you do with Matlab’s imagesc

Say you have a very rectangular 2D array arr, whose columns and rows correspond to very specific sampling locations x and y. That is, the arr[i, j] entry corresponds to some measurement taken at x[j] and y[i].

Matlab’s imagesc shows you this quite meaningfully:

x = linspace(-100, -10, 10);
y = [-8 -3];
data = randn(numel(y), numel(x));