0

我在使用新对象时遇到了一个问题uiaxes:绘制我的数据后,我可以单击数据点,然后它会显示一个显示 X 和 Y 数据的数据提示。当我将 X 轴的刻度更改为对数时,不会显示数据提示。

我正在使用 MATLAB 2019a。

这是一个示例代码:

h = uiaxes;
h.XScale = 'log';
a = plot( 1 : 10 );

通过将比例更改回线性,数据提示将再次正确显示。

我还尝试了以下命令以启用数据提示,它可以正常工作,但我的命令窗口上有大量警告说WindowMouseMotion回调中发生错误。

cursorMode = datacursormode(h.Parent);
cursorMode.Enable = 'on'
4

1 回答 1

2

看一下这个:

function [] = q56982381()
hF = uifigure(); hAx = uiaxes(hF);
hAx.XScale = 'log';
hP = plot( hAx, 1 : 10 );

% Invoke the datacursor manager:
dcm_obj = datacursormode(hF);
hTip = dcm_obj.createDatatip(hP); % Don't specify any further inputs at this stage

% Wait until the figure loaded:
drawnow; pause(0.1); % or mlapptools.waitForFigureReady(hF); (see note at the bottom)

% Modify the datatip position:
hTip.Position = [2, 2, 0];

结果是:

在此处输入图像描述

mlapptools实用程序是我共同创作的,旨在帮助使用和自定义 UIFigure。

于 2019-07-11T08:46:51.867 回答