John
John

Reputation: 5915

How to examine the value of a cell in a pcolor plot using the data cursor?

I have a MATLAB pcolor plot. Say something like this:

ixx = 1:10;
ixy = 2:2:25;
[x,y] = meshgrid(ixx, ixy);
pcolor(ixx, ixy, x+y)

When I use the data cursor, I don't get the value of the height of the cell, just the locations of the boundary of the cell:

example

Is there a way to force the cell value to appear in this plot? The associated cell should have value 23, not z = 0.

Note: In my real example, my axes are not uniform, so pcolor is required here (as opposed to moving to imagesc or similar, which does properly handle the data cursor).

Note: pcolor "hides" the top row and right most column of data. [Not directly relevant to the question, but an important aspect of pcolor]

Upvotes: 0

Views: 1440

Answers (1)

Sardar Usama
Sardar Usama

Reputation: 19689

Use the handle of pcolor to modify ZData i.e.

ph = pcolor(ixx, ixy, x+y);
ph.ZData = ph.CData;    % or   set(ph, 'ZData', get(ph,'CData'));

Result:

result

Upvotes: 3

Related Questions