Discussion:
Data cursor precision
(too old to reply)
v***@hotmail.com
2005-09-23 20:35:38 UTC
Permalink
How do I set the precision with which the data cursor returns values.
I often plot >1e7 points and ideally I'd like 9 digit or better
precision. Unfortunately, even when I zoom in on the plot, it still
gives me values like 1.1e7, whereas I'd like 11000001.
Any suggestions?
v***@hotmail.com
2005-09-26 18:52:33 UTC
Permalink
Hmm, this group is not as helpful as I hoped so after a few days
I figured it out myself. For anyone interested my solution is to
create two functions:

-------

function txt = myupdatefcn(empt,event_obj,str)
pos = get(event_obj,'Position');
px = sprintf(str,pos(1));
py = sprintf(str,pos(2));
txt = {['X: ' , px],['Y: ' , py]};

----------

and

----------

function ret = fixplot1(str),

set(datacursormode(gcf),'UpdateFcn',{@myupdatefcn, str});

---------

Now something like:

plot(1:1e7), fixplot1('%9.1f');

does what I want.
Mike
2010-10-27 16:58:04 UTC
Permalink
This will fix you problem permanently:

http://www.mathworks.de/matlabcentral/newsreader/view_thread/270109
Post by v***@hotmail.com
Hmm, this group is not as helpful as I hoped so after a few days
I figured it out myself. For anyone interested my solution is to
-------
function txt = myupdatefcn(empt,event_obj,str)
pos = get(event_obj,'Position');
px = sprintf(str,pos(1));
py = sprintf(str,pos(2));
txt = {['X: ' , px],['Y: ' , py]};
----------
and
----------
function ret = fixplot1(str),
---------
plot(1:1e7), fixplot1('%9.1f');
does what I want.
Alex Wineteer
2016-10-26 20:14:03 UTC
Permalink
Post by Mike
http://www.mathworks.de/matlabcentral/newsreader/view_thread/270109
Post by v***@hotmail.com
Hmm, this group is not as helpful as I hoped so after a few days
I figured it out myself. For anyone interested my solution is to
-------
function txt = myupdatefcn(empt,event_obj,str)
pos = get(event_obj,'Position');
px = sprintf(str,pos(1));
py = sprintf(str,pos(2));
txt = {['X: ' , px],['Y: ' , py]};
----------
and
----------
function ret = fixplot1(str),
---------
plot(1:1e7), fixplot1('%9.1f');
does what I want.
Right click on the plot you are trying to get data points for while in data cursor mode. Select "edit text update function"
Change the 4s in the output_text structure index to be whatever precision you want. (I changed to 10 digits).
Save the new callback as whatever you want. Then right click again on the figure and "select text update function." Select the new callback you just made.
CARLOS SILVA
2020-09-09 18:54:37 UTC
Permalink
Alex Wineteer,
It was very helpful for me!
Thank you very much!

Loading...