Clear Filters
Clear Filters

Why does Pcolor reduce the resolution of my n x m matrix

3 views (last 30 days)
I am trying to make a plot of a matrix T (n x m) which corresponds to data at n-depth levels 'Z', evolving over m timestamps 't'. I always used to use imagesc(, but somehow this gives me a blank figure (???). t is slightly irregularly spaced, Z is regular.
Alternatively plotting imagesc(T) gives a nice plot, but I would prefer imagesc(t,Z,T) to work. Instead using pcolor() gives an ugly plot, which looks like an imagesc of n/6 columns only. What's going on?

Answers (1)

Star Strider
Star Strider on 3 Mar 2017
The pcolor function uses the edges to define the patch colours, so it is ‘trimmed’ by one row and one column.
Use the image function instead.
  7 Comments
Adam
Adam on 3 Mar 2017
If you have irregularly space data I would suggest interpolating it onto a regular grid.
Personally I always use imagesc (and have only ever heard of pcolor from questions in the forum and never really knew what it did or why since its name does not convey to me anything that would suggest I'd want to plot an image with it!), but it depends what you are plotting and what you want to get from it.
I work with images that are recorded data rather than pictures (as you appear to be doing) so imagesc does exactly what I want, stretching the colourmap (though admittedly I usually over-ride this myself anyway). I have never had any desire to use imshow, but I know other people like it and I guess for photograph/picture type images it works fine and you don't have to map your data via a colourmap (though images either come with a colourmap or are greyscale or true RGB anyway so that is not difficult).
Walter Roberson
Walter Roberson on 3 Mar 2017
"If you have irregularly space data I would suggest interpolating it onto a regular grid."
pcolor / texture mapping is more efficient, in that it allows you to offload that work to your graphics hardware. That can make a significant difference if you are animating by updating coordinates.

Sign in to comment.

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!