I have a 2d matrix of values which I would like to plot as a 2d histogram.
A simplified example:
I have a 1d array of initial velocities, say vi = [1, 2, 3]
, and for each value in vi
, I have a row of corresponding final velocities stored in a 2d array, vf = [ [0.7, 1.1, 1.5], [1.8, 2.1, 2.4], [2.7, 2.9, 3.1] ]
.
I want to be able to make a 2d histogram of the points (vi, vf)
, i.e., the coordinates [1, 0.7], [1, 1.1], [1, 1.5], [2, 1.8], [2, 2.1], [2, 2.4], and [3,2.7], [3, 2.9], [3, 3.1]
.
Is there a way to create such parings?
The answer to this question advises to use imshow or matshow, but that colors bins by the value assigned to each element. What I need is a plotting routine that takes a 2d matrix, divides it into a grid, and colors each bin by the count in each bin.
Any help is appreciated!