# How to plot a price level matrix in Matlab?

I have a matrix P of m rows and n columns. P(i,j) contains the price of occupying position i at time j. I want to plot this in Matlab but in a way to get some kind of density plot with different price levels corresponding to different colors. An example of the output would be something like this:

I just found the in-built function I was looking for: "imagesc".

For example:

>> imagesc(eye(4)); colorbar

gives this

A filled 2-d contour plot seems to be what you are looking for.

Assuming you have vectors (or matrices) "position" and "time", the following snippet should work (modulo an apostrophe or two)

contourf(position,time,P);
colorbar;

• I just updated the wanted plot, I want something simple just a linear mapping of the price to the color, but thanks for the suggestion! – abdeaitali Dec 9 '15 at 17:20

What about just using surface plot? Something like:

surf(P); view(0,90);


or for more options something like:

surf(P,'EdgeColor','none','facecolor','interp'); view(0,90); colormap('hot')