0
$\begingroup$

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: enter image description here

$\endgroup$
2
$\begingroup$

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

For example:

>> imagesc(eye(4)); colorbar

gives this

enter image description here

$\endgroup$
0
$\begingroup$

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;
$\endgroup$
  • $\begingroup$ 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! $\endgroup$ – abdeaitali Dec 9 '15 at 17:20
0
$\begingroup$

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')
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.