Colormap color levels on cursor

조회 수: 5 (최근 30일)
Mooner Land
Mooner Land 2019년 10월 16일
댓글: Mooner Land 2019년 10월 19일
I have a 3 column matrix which is x,y, and C. x and y values are coordinates and C value is intensity. I plot a diagram with using "patch" command.
On figure i just get x and y values on cursor. I want to see intenstiy values on colormap. How can i do it?
Note:
I have tried before meshgrid and countourf but it takes a lot of time to create figure because i have many data points. I use for loop for every rectangle so it takes a lot of time. When i do not use for loop it creates a wrong shape.
Anyone can help me?
  댓글 수: 3
Adam
Adam 2019년 10월 17일
You can write your own Data cursor function
doc datacursormode
shows an example of this if you look for the UpdateFcn. It isn't necessarily trivial though. You'd likely have to use the axes' CurrentPoint property and work out which patch is currently under the mouse.
Alternatively I guess you could program your own functionality entirely using the ButtonDownFcn property of the patch objects (or of the axes objects if you can work out which patch is under the mouse. Doing tis on the axes though would require the patches to have their 'HitTest' set to off, otherwise the axes won't pick up mouse clicks under patches).
Mooner Land
Mooner Land 2019년 10월 17일
hi darova,
here is my code,
a=load('a.txt');
cor=[a(:,1) a(:,2)];
m1=a(:,3);
ff=reshape( 1:length(cor), 4, length(cor)/4)';
figure
p=patch('Faces',ff,'Vertices',cor,'FaceVertexCData',m1,'FaceColor','interp')
colormap(flipud(jet(15)))
shading interp
colorbar
set(p, 'edgecolor','black')
i want to see 'FaceVertexCData',m1 values on plot with datacursor. i just see cor values as X and Y.
hi Adam,
i take a look your advice but i cant understand, i am new at matlab

댓글을 달려면 로그인하십시오.

채택된 답변

darova
darova 2019년 10월 17일
Here is direction
You have position of cursor in variable pos
You can access to FaceVertexCData with command
get(h,'FaceVertexCData')
You can access to XY data too:
get(h,'Vertices')
So all you have to do is to find some connection between all this data. Find index of pos in Vertices data and use it to display FaceVertexCData
123.png
  댓글 수: 12
Mooner Land
Mooner Land 2019년 10월 19일
thank you darova,
where should i copy this .m file? i want to run this code when i open matlab everytime.
i have many data to plot, so i want to draw and get values every time when i run this code. actually i want to create a gui program with this.
Mooner Land
Mooner Land 2019년 10월 19일
ok darova,
i can do it now :)
i rename .m file and copy it my current directory so it runs :)
how can i do this function as matlab's default function. ehich folder should i copy?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by