How to move data tip in R2025b? (Or, how to restore legacy data tip behavior)

조회 수: 102 (최근 30일)
Kristin Kaspersen
Kristin Kaspersen 2025년 11월 17일 10:37
댓글: Catalytic 2025년 11월 20일 17:18
In previous versions of matlab, an existing data tip would move to a new point whenever I clicked on a new point in a graph or image, and I could also use the arrows on the keyboard to move the data tip one pixel at a time. In R2025b I get a new data tip each time I click somewhere in a plot, and there does not seem to be any way to move the data tips to a different point. How can I make the data tips behave like they did before? I never want to have hundreds of data tips in a plot, so holding shift while clicking in order to create a second data tip is not a problem.

채택된 답변

Matt J
Matt J 2025년 11월 17일 16:42
편집: Matt J 2025년 11월 17일 16:42
Another option is to supply your own datatip, with an UpdateFcn defined by you:
function datatipDemo()
% Minimal example that restores "single movable data tip" behavior
% in MATLAB R2025b by simply assigning a custom UpdateFcn.
% Make a demo image
I = peaks(200);
imagesc(I); axis image; colormap parula
title('Click anywhere; arrow keys move the data tip')
% --- KEY: Use datacursormode and set a custom UpdateFcn ---
hdt = datacursormode(gcf);
hdt.UpdateFcn = @myUpdateFcn;
datacursormode on;
end
function out = myUpdateFcn(~, evt)
% Very simple update function. No indexing, overlays, etc.
pos = evt.Position;
val = evt.Target.CData(round(pos(2)), round(pos(1)));
out = {
sprintf('x = %d', round(pos(1)))
sprintf('y = %d', round(pos(2)))
sprintf('value = %.3f', val)
};
end
  댓글 수: 4
Rik
Rik 2025년 11월 20일 13:19
이동: Matt J 2025년 11월 20일 13:36
You can edit startup.m to change the figure creation function to do this every time a new figure is created.
Matt J
Matt J 2025년 11월 20일 13:38
@Rik No, unfortunately the figure creation function will not work because it gets run before the axes is created, meaning that all the datacursor settings get overwritten later once the axes is created. You must use the defaultAxesCreateFcn instead.

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

추가 답변 (2개)

Matt J
Matt J 2025년 11월 17일 14:18
You can activate the old-style figure toolbar exploration buttons, e.g.,
addToolbarExplorationButtons(gcf)
That seems to have the old datacursor behavior.
  댓글 수: 8
Kristin Kaspersen
Kristin Kaspersen 2025년 11월 19일 10:34
It does this for other people as well, but you're less likely to experience it if you have a wide screen instead of a dual monitor setup with smaller screens. If you have a wide screen, you may be able to open 30-40 windows before the bug occurs, whereas for me it happens when I get to somewhere around 15-20 open windows. (Here's just one of several examples of other people with the same experience as me: https://learn.microsoft.com/en-us/answers/questions/1481864/windows-11-taskbar-width)
Matt J
Matt J 2025년 11월 19일 15:14
OK, I think I managed to reprdouce it. In any case, did you try my other answer? It restores the old datatip behavior entirely.

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


Catalytic
Catalytic 2025년 11월 17일 17:58
there does not seem to be any way to move the data tips to a different point
Hold the shift key down while you press the arrow keys.
  댓글 수: 5
Matt J
Matt J 2025년 11월 20일 17:00
In previous versions of Matlab, you could move the data tip to a different curve by clicking,
By clicking perhaps, but with the arrow keys?
Catalytic
Catalytic 2025년 11월 20일 17:18
Also possibly useful -- I find in R2025b that when you hold down the shift key, any data tip you place will self-delete once the mouse button is released. This works both in images and line plots.
It doesn't give you the exact same experience as before, but it does provide a way to probe multiple points without the plot getting cluttered with data tips, and without the extra key strokes needed to explicitly delete data tips.

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

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

제품


릴리스

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by