{"id":1455,"date":"2015-10-09T09:41:01","date_gmt":"2015-10-09T13:41:01","guid":{"rendered":"https:\/\/blogs.mathworks.com\/steve\/?p=1455"},"modified":"2019-11-01T12:11:04","modified_gmt":"2019-11-01T16:11:04","slug":"improved-dashed-and-dotted-lines-in-eps-files","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/steve\/2015\/10\/09\/improved-dashed-and-dotted-lines-in-eps-files\/","title":{"rendered":"Improved dashed and dotted lines in EPS files"},"content":{"rendered":"<div class=\"content\"><p>At the ICIP (International Conference on Image Processing) last week, a customer stopped by the MathWorks booth to chat. He said that he regularly uses one of the File Exchange submissions that \"fixes\" dashed and dotted lines in EPS files exported by MathWorks. so I spent some time looking into that issue this week.<\/p><p>I found that the new MATLAB graphics system introduced in R2014b has greatly improved the appearance of dashed and dotted lines in exported EPS files. Here's an illustration. (My test figure was inspired by the screen shot in the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/23604-fix-lines\">fix_lines<\/a> submission on the File Exchange.)<\/p><pre class=\"codeinput\">widths = [0.5 1.0 2.0 5.0 10.0];\r\nstyles = {<span class=\"string\">':'<\/span>,<span class=\"string\">'-.'<\/span>,<span class=\"string\">'--'<\/span>};\r\n\r\n[ii,jj] = meshgrid(1:length(widths),1:length(styles));\r\n\r\nx = [0 1];\r\nlegend_strings = {};\r\nhold <span class=\"string\">on<\/span>\r\n<span class=\"keyword\">for<\/span> k = 1:numel(ii)\r\n   y = [k k];\r\n   style_k = styles{jj(k)};\r\n   width_k = widths(ii(k));\r\n   legend_strings{end+1} = sprintf(<span class=\"string\">'%s %.1f'<\/span>,style_k,width_k);\r\n   plot(x,y,<span class=\"string\">'LineStyle'<\/span>,style_k,<span class=\"string\">'LineWidth'<\/span>,width_k,<span class=\"keyword\">...<\/span>\r\n      <span class=\"string\">'Color'<\/span>,<span class=\"string\">'k'<\/span>);\r\n<span class=\"keyword\">end<\/span>\r\nylim([0, numel(ii)+1])\r\nhold <span class=\"string\">off<\/span>\r\nax = gca;\r\nset(ax,<span class=\"string\">'YTick'<\/span>,1:numel(ii),<span class=\"keyword\">...<\/span>\r\n    <span class=\"string\">'YTickLabel'<\/span>,legend_strings,<span class=\"keyword\">...<\/span>\r\n    <span class=\"string\">'TickLength'<\/span>,[0 0],<span class=\"keyword\">...<\/span>\r\n    <span class=\"string\">'XTick'<\/span>,[]);\r\n<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/improved_dashed_dotted_eps_lines_01.png\" alt=\"\"> <p>Here is a 100 DPI rendering of the EPS output from R2014a:<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/lines_r2014a.png\" alt=\"\"> <\/p><p>I can understand why people wanted to \"fix\" that.<\/p><p>Here is a rendering of the EPS output from R2015b. (It looks like this for releases R2014b or later.)<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/lines_r2015b.png\" alt=\"\"> <\/p><p>That's much better.<\/p><p>So if you have been using a File Exchange submission such as <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/15743-fix-dashed-and-dotted-lines-in-eps-export\">\"Fix dashed and dotted lines in EPS export\"<\/a> or <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/23604-fix-lines\">fix_lines<\/a>, you might want to check out R2014b or later.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_a41ec143d9b64b928c7e53a092ba9b30() {\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='a41ec143d9b64b928c7e53a092ba9b30 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' a41ec143d9b64b928c7e53a092ba9b30';\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 2015 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_a41ec143d9b64b928c7e53a092ba9b30()\"><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; R2015b<br><\/p><\/div><!--\r\na41ec143d9b64b928c7e53a092ba9b30 ##### SOURCE BEGIN #####\r\n%%\r\n% At the ICIP (International Conference on Image Processing) last\r\n% week, a customer stopped by the MathWorks booth to chat. He\r\n% said that he regularly uses one of the File Exchange submissions that\r\n% \"fixes\" dashed and dotted lines in EPS files exported by\r\n% MathWorks. so I spent some time looking into that issue this week.\r\n%\r\n% I found that the new MATLAB graphics system introduced in\r\n% R2014b has greatly improved the appearance of dashed and dotted\r\n% lines in exported EPS files. Here's an illustration. (My test\r\n% figure was inspired by the screen shot in the <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/23604-fix-lines\r\n% fix_lines> submission on the File Exchange.)\r\n\r\nwidths = [0.5 1.0 2.0 5.0 10.0];\r\nstyles = {':','-.','REPLACE_WITH_DASH_DASH'};\r\n\r\n[ii,jj] = meshgrid(1:length(widths),1:length(styles));\r\n\r\nx = [0 1];\r\nlegend_strings = {};\r\nhold on\r\nfor k = 1:numel(ii)\r\n   y = [k k];\r\n   style_k = styles{jj(k)};\r\n   width_k = widths(ii(k));\r\n   legend_strings{end+1} = sprintf('%s %.1f',style_k,width_k);\r\n   plot(x,y,'LineStyle',style_k,'LineWidth',width_k,...\r\n      'Color','k');\r\nend\r\nylim([0, numel(ii)+1])\r\nhold off\r\nax = gca;\r\nset(ax,'YTick',1:numel(ii),...\r\n    'YTickLabel',legend_strings,...\r\n    'TickLength',[0 0],...\r\n    'XTick',[]);\r\n\r\n%%\r\n% Here is a 100 DPI rendering of the EPS output from R2014a:\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/steve\/files\/lines_r2014a.png>>\r\n%\r\n% I can understand why people wanted to \"fix\" that.\r\n%\r\n% Here is a rendering of the EPS output from R2015b. (It \r\n% looks like this for releases R2014b or later.)\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/steve\/files\/lines_r2015b.png>>\r\n%\r\n% That's much better.\r\n%\r\n% So if you have been using a File Exchange submission such as <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/15743-fix-dashed-and-dotted-lines-in-eps-export \r\n% \"Fix dashed and dotted lines in EPS export\"> or\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/23604-fix-lines\r\n% fix_lines>, you might want to check out R2014b or later.\r\n\r\n\r\n##### SOURCE END ##### a41ec143d9b64b928c7e53a092ba9b30\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/steve\/files\/improved_dashed_dotted_eps_lines_01.png\" onError=\"this.style.display ='none';\" \/><\/div><p>At the ICIP (International Conference on Image Processing) last week, a customer stopped by the MathWorks booth to chat. He said that he regularly uses one of the File Exchange submissions that... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/steve\/2015\/10\/09\/improved-dashed-and-dotted-lines-in-eps-files\/\">read more >><\/a><\/p>","protected":false},"author":42,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[80,90,705,30,162,68,270,298],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1455"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/comments?post=1455"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1455\/revisions"}],"predecessor-version":[{"id":1457,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/posts\/1455\/revisions\/1457"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/media?parent=1455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/categories?post=1455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/steve\/wp-json\/wp\/v2\/tags?post=1455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}