下面是解决方案!向图上的数据点添加额外信息
这(X,Y)值实际上相当于吨价,这是我想看到的情节。我能做什么?
显然MATLAB在数据点框中显示多个信息的能力:
只是把它作为 “TimePlot(X,Y,T)”,它会工作。我相信这个代码也说明了修改数据提示的几个关键点。
function TimePlot(varargin)
x=varargin{1};
y=varargin{2};
t=varargin{nargin};
fh=figure;
plot(varargin{1:nargin-1})
function output_txt = myfunction(obj,event_obj)
% Display the position of the data cursor
% obj Currently not used (empty)
% event_obj Handle to event object
% output_txt Data cursor text string (string or cell array of strings).
pos = get(event_obj,'Position');
ind=intersect(Find(x,pos(1),1e-10),Find(y,pos(2),1e-10));
if(length(ind)~=1)
text='err';
else
text=num2str(t(ind),4);
end
output_txt = {['X: ',num2str(pos(1),4)],...
['Y: ',num2str(pos(2),4)],['T: ',text]};
% If there is a Z-coordinate in the position, display it as well
if (length(pos) > 2)
output_txt{end+1} = ['Z: ',num2str(pos(3),4)];
end
end
dcm=datacursormode(fh);
datacursormode on
set(dcm,'updatefcn',@myfunction)
end
function [ out ] = Find(vector, value ,precision)
if nargin < 3
precision = 0.0001;
end
out=[];
for i=1:length(vector)
if(abs(vector(i)-value)<precision)
out=[out i];
end
end
end
请你想如何做到这一点更为具体。如果您有更具体的编码问题,请编辑您的问题。否则,它是关于StackOverflow的话题(你可能会在SuperUser上获得帮助) – ryanyuyu
[**这是一个关于如何做这个**的教程](http://blogs.mathworks.com/videos/2011/ 19分之10/教程如何对化妆一个定制数据-踩加速器踏板与Matlab /)。 – thewaywewalk
或cunsult这个重复的问题[数据提示定制在matlab图](http://stackoverflow.com/questions/12100086/data-tip-customization-in-matlab-figure) – thewaywewalk