{"id":8612,"date":"2017-09-08T09:00:07","date_gmt":"2017-09-08T13:00:07","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=8612"},"modified":"2017-11-03T18:37:15","modified_gmt":"2017-11-03T22:37:15","slug":"cursorbar","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2017\/09\/08\/cursorbar\/","title":{"rendered":"Cursorbar"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\n   <introduction><\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>&#8216;s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49612-cursorbar\">Cursorbar<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1189163\">Marjorie<\/a>.\n      <\/p>\n<p>   <\/introduction><\/p>\n<p>I really like both <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/visual-inspection-of-signal-data.html\">Simulink Data Inspector<\/a> and the new <a href=\"https:\/\/www.mathworks.com\/help\/signal\/ref\/signalanalyzer-app.html\">Signal Analyzer App<\/a> for comparing and analyzing signal data.  They make it easy to rapidly compare lots of signals, and with the Signal Analyzer to see the <a href=\"https:\/\/www.mathworks.com\/help\/signal\/ug\/spectrum-computation-in-signal-analyzer.html\">spectrum<\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/signal\/ug\/spectrogram-computation-in-signal-analyzer.html\">spectrogram<\/a> in the same window as the signal.  Additionally, they also have data cursors that allow me to scan the values of multiple signals at the same time.  Here&#8217;s a screen shot of all of the features I just mentioned:\n   <\/p>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainCursorbar\/signalanalyzer.png\"> <\/p>\n<p>So what if you want a data cursor on a regular MATLAB plot?  Well now you can with Marjorie&#8217;s <tt>cursorbar<\/tt>.  Cursorbar gives you plenty of control over its appearance and behavior to meet all of your data cursor needs.\n   <\/p>\n<p>Look at the help for a whole slew of examples!  Here&#8217;s the 9th one:<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #228B22\">% Create line plot<\/span>\r\nx = linspace(0,14,201);\r\ny = sin(2*pi*x\/3);\r\nh = plot(x,y,<span style=\"color: #A020F0\">':k'<\/span>,<span style=\"color: #A020F0\">'LineWidth'<\/span>,2);\r\nylim([-1.2 1.2])\r\n\r\n<span style=\"color: #228B22\">% Define colors<\/span>\r\ntopMarkers = <span style=\"color: #A020F0\">'x+*o.sdv^&gt;&lt;ph'<\/span>; <span style=\"color: #228B22\">% top marker styles<\/span>\r\nbottomMarkers = <span style=\"color: #A020F0\">'x+*o.sd^v&lt;&gt;hp'<\/span>; <span style=\"color: #228B22\">% bottom marker styles<\/span>\r\ntargetMarkers = <span style=\"color: #A020F0\">'+xo*.dsddddhp'<\/span>; <span style=\"color: #228B22\">% target marker styles<\/span>\r\nlineColor = lines(13); <span style=\"color: #228B22\">% cursorbar colors<\/span>\r\n\r\n<span style=\"color: #228B22\">% Create cursorbars<\/span>\r\n<span style=\"color: #0000FF\">for<\/span> ii=13:-1:1\r\n    c(ii) = graphics.Cursorbar(h,<span style=\"color: #A020F0\">'Location'<\/span>,ii);\r\n    <span style=\"color: #228B22\">%<\/span>\r\n    c(ii).TopMarker = topMarkers(ii);\r\n    c(ii).BottomMarker = bottomMarkers(ii);\r\n    c(ii).TargetMarkerStyle = targetMarkers(ii);\r\n    <span style=\"color: #228B22\">%<\/span>\r\n    c(ii).CursorLineColor = lineColor(ii,:);\r\n    c(ii).TargetMarkerEdgeColor = 1-lineColor(ii,:);\r\n    <span style=\"color: #228B22\">%<\/span>\r\n    c(ii).TopHandle.MarkerSize = 12;\r\n    c(ii).BottomHandle.MarkerSize = 12;\r\n<span style=\"color: #0000FF\">end<\/span>\r\n<span style=\"color: #228B22\">%<\/span>\r\nset(c,<span style=\"color: #A020F0\">'ShowText'<\/span>,<span style=\"color: #A020F0\">'off'<\/span>,<span style=\"color: #A020F0\">'TargetMarkerSize'<\/span>,12,<span style=\"color: #A020F0\">'TargetMarkerFaceColor'<\/span>,<span style=\"color: #A020F0\">'w'<\/span>)<\/pre>\n<p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainCursorbar\/cursorbar.png\"> <\/p>\n<h3>Comments<a name=\"3\"><\/a><\/h3>\n<p>Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=8612#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49612-cursorbar#comments\">comment<\/a> for Marjorie.\n   <\/p>\n<p><script language=\"JavaScript\">\n<!--\n\n    function grabCode_d6d94d1eaa88404081f4051a944c1d6a() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='d6d94d1eaa88404081f4051a944c1d6a ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' d6d94d1eaa88404081f4051a944c1d6a';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Sean de Wolski';\n        copyright = 'Copyright 2017 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }   \n      \n-->\n<\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><a href=\"javascript:grabCode_d6d94d1eaa88404081f4051a944c1d6a()\"><span style=\"font-size: x-small;        font-style: italic;\">Get<br \/>\n            the MATLAB code<br \/>\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>      Published with MATLAB&reg; R2017a<\/p>\n<\/div>\n<p><!--\nd6d94d1eaa88404081f4051a944c1d6a ##### SOURCE BEGIN #####\n%% Cursorbar\n%\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s pick this week is\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49612-cursorbar Cursorbar> by\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/1189163 Marjorie>.\n% \n\n%% \n%\n% I really like both\n% <https:\/\/www.mathworks.com\/help\/simulink\/ug\/visual-inspection-of-signal-data.html\n% Simulink Data Inspector> and the new\n% <https:\/\/www.mathworks.com\/help\/signal\/ref\/signalanalyzer-app.html Signal\n% Analyzer App> for comparing and analyzing signal data.  They make it easy\n% to rapidly compare lots of signals, and with the Signal Analyzer to see\n% the\n% <https:\/\/www.mathworks.com\/help\/signal\/ug\/spectrum-computation-in-signal-analyzer.html\n% spectrum> and\n% <https:\/\/www.mathworks.com\/help\/signal\/ug\/spectrogram-computation-in-signal-analyzer.html\n% spectrogram> in the same window as the signal.  Additionally, they also\n% have data cursors that allow me to scan the values of multiple signals at\n% the same time.  Here's a screen shot of all of the features I just\n% mentioned:\n%\n% <<signalanalyzer.png>>\n%\n% So what if you want a data cursor on a regular MATLAB plot?  Well now you\n% can with Marjorie's |cursorbar|.  Cursorbar gives you plenty of\n% control over its appearance and behavior to meet all of your data cursor\n% needs.\n%\n% Look at the help for a whole slew of examples!  Here's the 9th one:\n\n% Create line plot\nx = linspace(0,14,201);\ny = sin(2*pi*x\/3);\nh = plot(x,y,':k','LineWidth',2);\nylim([-1.2 1.2])\n\n% Define colors\ntopMarkers = 'x+*o.sdv^><ph'; % top marker styles\nbottomMarkers = 'x+*o.sd^v<>hp'; % bottom marker styles\ntargetMarkers = '+xo*.dsddddhp'; % target marker styles\nlineColor = lines(13); % cursorbar colors\n\n% Create cursorbars\nfor ii=13:-1:1\n    c(ii) = graphics.Cursorbar(h,'Location',ii);\n    %\n    c(ii).TopMarker = topMarkers(ii);\n    c(ii).BottomMarker = bottomMarkers(ii);\n    c(ii).TargetMarkerStyle = targetMarkers(ii);\n    %\n    c(ii).CursorLineColor = lineColor(ii,:);\n    c(ii).TargetMarkerEdgeColor = 1-lineColor(ii,:);\n    %\n    c(ii).TopHandle.MarkerSize = 12;\n    c(ii).BottomHandle.MarkerSize = 12;\nend\n%\nset(c,'ShowText','off','TargetMarkerSize',12,'TargetMarkerFaceColor','w')\n\n%%\n%\n% <<cursorbar.png>>\n\n%% Comments\n% \n% Give it a try and let us know what you think\n% <https:\/\/blogs.mathworks.com\/pick\/?p=8612#respond here> or leave a\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/49612-cursorbar#comments\n% comment> for Marjorie.\n##### SOURCE END ##### d6d94d1eaa88404081f4051a944c1d6a\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainCursorbar\/signalanalyzer.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>Sean&#8216;s pick this week is Cursorbar by Marjorie.<\/p>\n<p>I really like both Simulink Data Inspector and the new Signal Analyzer App for comparing and analyzing signal data.  They make it&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2017\/09\/08\/cursorbar\/\">read more >><\/a><\/p>\n","protected":false},"author":87,"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\/8612"}],"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\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=8612"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8612\/revisions"}],"predecessor-version":[{"id":8932,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/8612\/revisions\/8932"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=8612"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=8612"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=8612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}