title: Adding extra information to datapoints on a plot
body: <p>THERE IS THE SOLUTION BELOW!</p>
  
  <p><img src="https://i.stack.imgur.com/OZwWy.png" alt="enter image description here"></p>
  
  <p>This (x,y) value actually corresponds to a t value, which I want to see on the plot. What can I do?</p>
  
  <p>Clearly matlab has the ability to display multiple information in the datapoint box:</p>
  
  <p><img src="https://i.stack.imgur.com/3vxDa.png" alt="enter image description here">
  just call it as "TimePlot(x,y,t)" and it will work. This code, I believe, also illustrates a few key points in modifying datatips.
  <div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>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) &gt; 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 &lt; 3
      precision =   0.0001;
  end
  
  out=[];
  
  for i=1:length(vector)
      
      if(abs(vector(i)-value)&lt;precision)
          out=[out i];
      end
  
  end
  
  end</code></pre>
  </div>
  </div>
  </p>