{"id":10502,"date":"2019-02-08T10:41:16","date_gmt":"2019-02-08T15:41:16","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=10502"},"modified":"2019-03-19T11:27:09","modified_gmt":"2019-03-19T15:27:09","slug":"draggable-data-tips","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2019\/02\/08\/draggable-data-tips\/","title":{"rendered":"Draggable Data Tips"},"content":{"rendered":"\r\n\r\n<div class=\"content\"><p><a href=\"http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869871\">Jiro<\/a>&#8216;s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/69799\"><tt>DragDataTip<\/tt><\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/8272669\">Allen<\/a>.<\/p><p>Here&#8217;s a simple, but quite useful utility to use in conjunction with MATLAB&#8217;s <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/creating_plots\/interactively-explore-plotted-data.html#mw_cb7a9f7b-8f0c-48b1-bd81-3f9d30e84388\">data tips<\/a>. It customizes the data tips so that you can drag the labels to any location for better visibility.<\/p><p>The entry requires you to also download and install <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4179\"><tt>draggable<\/tt><\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869669\">Francois Bouffard<\/a>. It is also worth noting that Allen&#8217;s entry was inspired by an earlier entry, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/44065\">Draggable data tips<\/a>, by the famous <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/642467\">Yair Altman<\/a>. (Note that Yair&#8217;s entry does not run on R2014b or newer.)<\/p><p>Here&#8217;s an example of Allen&#8217;s entry in action.<\/p><pre class=\"language-matlab\">hFig = figure;\r\nhLin = plot(peaks);\r\ngrid <span class=\"string\">on<\/span>\r\ntitle(<span class=\"string\">'Draggable Data Tips'<\/span>)\r\nxlabel(<span class=\"string\">'Data Index Values'<\/span>)\r\nylabel(<span class=\"string\">'Acceleration (g''s)'<\/span>)\r\nhFig.KeyPressFcn = {@DragDataTip,gca};\r\n<\/pre><p>Then create some data tips using the built-in feature. Once you&#8217;re done (and turned off the datacursor mode), press Ctrl-M. This converts the standard data tips to Drag Data Tips. Then you can move the data tips to any location.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_dragdatatip\/dragdatatip_screenshot.png\" alt=\"\"> <\/p><p>See this in action.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_dragdatatip\/dragdatatip_anim.gif\" alt=\"\"> <\/p><p>You can find other examples in the help of <tt>DragDataTip<\/tt>.<\/p><pre class=\"language-matlab\">help <span class=\"string\">DragDataTip<\/span>\r\n<\/pre><p><b>Comments<\/b><\/p><p>Give it a try and let us know what you think <a href=\"http:\/\/blogs.mathworks.com\/pick\/?p=10502#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/69799#comment\">comment<\/a> for Allen.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_beab44d3c6ef4edf8547df596067416c() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='beab44d3c6ef4edf8547df596067416c ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' beab44d3c6ef4edf8547df596067416c';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2019 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_beab44d3c6ef4edf8547df596067416c()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2018b<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2018b<br><\/p><\/div><!--\r\nbeab44d3c6ef4edf8547df596067416c ##### SOURCE BEGIN #####\r\n%%\r\n% <http:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869871 Jiro>'s\r\n% pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/69799\r\n% |DragDataTip|> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/8272669 Allen>.\r\n%\r\n% Here's a simple, but quite useful utility to use in conjunction with\r\n% MATLAB's\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/creating_plots\/interactively-explore-plotted-data.html#mw_cb7a9f7b-8f0c-48b1-bd81-3f9d30e84388\r\n% data tips>. It customizes the data tips so that you can drag the labels\r\n% to any location for better visibility.\r\n%\r\n% The entry requires you to also download and install\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/4179 |draggable|>\r\n% by <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869669\r\n% Francois Bouffard>. It is also worth noting that Allen's entry was\r\n% inspired by an earlier entry,\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/44065 Draggable data\r\n% tips>, by the famous\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/642467 Yair\r\n% Altman>. (Note that Yair's entry does not run on R2014b or newer.)\r\n%\r\n% Here's an example of Allen's entry in action.\r\n%\r\n%   hFig = figure;\r\n%   hLin = plot(peaks);\r\n%   grid on\r\n%   title('Draggable Data Tips')\r\n%   xlabel('Data Index Values')\r\n%   ylabel('Acceleration (g''s)')\r\n%   hFig.KeyPressFcn = {@DragDataTip,gca};\r\n%\r\n% Then create some data tips using the built-in feature. Once you're done\r\n% (and turned off the datacursor mode), press Ctrl-M. This converts the\r\n% standard data tips to Drag Data Tips. Then you can move the data tips to\r\n% any location.\r\n%\r\n% <<dragdatatip_screenshot.png>>\r\n%\r\n% See this in action.\r\n%\r\n% <<dragdatatip_anim.gif>>\r\n%\r\n% You can find other examples in the help of |DragDataTip|.\r\n%\r\n%   help DragDataTip\r\n%\r\n% *Comments*\r\n%\r\n% Give it a try and let us know what you think\r\n% <http:\/\/blogs.mathworks.com\/pick\/?p=10502#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/69799#comment\r\n% comment> for Allen.\r\n\r\n##### SOURCE END ##### beab44d3c6ef4edf8547df596067416c\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/jiro\/potw_dragdatatip\/dragdatatip_screenshot.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n\r\nJiro&#8216;s pick this week is DragDataTip by Allen.Here&#8217;s a simple, but quite useful utility to use in conjunction with MATLAB&#8217;s data tips. It customizes the data tips so that you&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2019\/02\/08\/draggable-data-tips\/\">read more >><\/a><\/p>","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10502"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=10502"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10502\/revisions"}],"predecessor-version":[{"id":10598,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/10502\/revisions\/10598"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=10502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=10502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=10502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}