{"id":2565,"date":"2010-05-28T13:22:53","date_gmt":"2010-05-28T13:22:53","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2010\/05\/28\/creating-and-exporting-publication-quality-graphics\/"},"modified":"2016-05-18T11:14:54","modified_gmt":"2016-05-18T15:14:54","slug":"creating-and-exporting-publication-quality-graphics","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2010\/05\/28\/creating-and-exporting-publication-quality-graphics\/","title":{"rendered":"Creating and Exporting Publication-Quality Graphics"},"content":{"rendered":"<div class=\"content\">\r\n\r\n<a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911\">Brett<\/a>'s Pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/23629-export-fig\">export_fig<\/a>, by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/29192\">Oliver Woodford<\/a>.\r\n\r\nFrequently, when I'm bantering about MATLAB at cocktail parties, the question of how to create \"publication-quality\" graphics\r\nfrom MATLAB arises. Many of you do great work using our tools, but are stymied when it comes time to publish your results\r\nwith high-end plots and figures. To address these questions, I've started maintaining a list of resources that facilitate\r\nthe creation of such graphics; Oliver's \"export_fig\" has recently found its way onto my list.\r\n\r\n&nbsp;\r\n<h3>Contents<\/h3>\r\n<div>\r\n<ul>\r\n\t<li><a href=\"#1\">Oliver's contribution<\/a><\/li>\r\n\t<li><a href=\"#4\">Other useful resources and links<\/a><\/li>\r\n<\/ul>\r\n<\/div>\r\n<h3>Oliver's contribution<a name=\"1\"><\/a><\/h3>\r\nFunction <tt>export_fig<\/tt> is described on the File Exchange with this verbiage:\r\n\r\nThis function saves a figure or single axes to one or more vector and\/or bitmap file formats, and\/or outputs a rasterized\r\nversion to the workspace, with the following properties:\r\n<div>\r\n<ul>\r\n\t<li>Figure\/axes reproduced as it appears on screen<\/li>\r\n\t<li>Cropped borders (optional)<\/li>\r\n\t<li>Embedded fonts (vector formats)<\/li>\r\n\t<li>Improved line and grid line styles<\/li>\r\n\t<li>Anti-aliased graphics (bitmap formats)<\/li>\r\n\t<li>Render images at native resolution (optional for bitmap formats)<\/li>\r\n\t<li>Transparent background supported (pdf, eps, png)<\/li>\r\n\t<li>Semi-transparent patch objects supported (png only)<\/li>\r\n\t<li>RGB, CMYK or grayscale output (CMYK only with pdf, eps, tiff)<\/li>\r\n\t<li>Variable image compression, including lossless (pdf, eps, jpg)<\/li>\r\n\t<li>Optionally append to file (pdf only)<\/li>\r\n\t<li>Vector formats: pdf, eps<\/li>\r\n\t<li>Bitmap formats: png, tif, jpg, bmp, export to workspace<\/li>\r\n<\/ul>\r\n<\/div>\r\nThis function is especially suited to exporting figures for use in publications and presentations, because of the high quality\r\nand portability of media produced.\r\n\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/pick\/..\/images\/pick\/exportfigscreencap.jpg\" alt=\"\" hspace=\"5\" vspace=\"5\" \/>\r\n\r\nThere are several things I particularly like about <tt>export_fig<\/tt>. (Others have liked it, too; as of this writing, the entry was downloaded 737 times in the last month alone, and has an average\r\nuser rating of 4.9 out of 5, from 28 ratings!) The code is well-implemented, and appears to be pretty robust. Also, the function\r\nis nicely documented (though it might be useful to include an example or two).\r\n\r\nI also like how responsive Oliver has been in responding to queries and suggestions. The file has been updated 21 times (!)\r\nsince it was originally posted in April, 2009, largely in response to user suggestions and bug reports. That's responsive,\r\nand great use of the MATLAB Central File Exchange!\r\n<h3>Other useful resources and links<a name=\"4\"><\/a><\/h3>\r\nMathWorker <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/3024\">Ben Hinkle<\/a> wrote a two-part MATLAB Digest article many years ago that has stood the test of time. In part 1, he discussed the issue, and introduced his <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/727-exportfig\">exportfig<\/a>, with which one could control basic graphic properties and create EPS figures. In part 2, Ben also provided some additional functions, including the ability to preview or restore figures.\r\n\r\nFellow Pick-of-the-Week blogger <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a> guest blogged on <a href=\"https:\/\/blogs.mathworks.com\/loren\/\">\"Loren on the Art of MATLAB\"<\/a> about how to <a href=\"https:\/\/blogs.mathworks.com\/loren\/2007\/12\/11\/making-pretty-graphs\/\">\"make graphs pretty\"<\/a>.\r\n\r\nYou might also check out Oliver's <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/23604-fix-lines\">fix_lines<\/a> submission for \"Fixing Postscript Lines,\" <a href=\"https:\/\/blogs.mathworks.com\/pick\/2010\/01\/15\/fixing-postscript-lines\/\">featured<\/a> as a Pick of the Week back in January.\r\n\r\nFinally, these doc pages might be useful in this regard:\r\n<div>\r\n<ul>\r\n\t<li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/techdoc\/creating_plots\/f3-103236.html\">\u201cChoosing a Graphics Format\u201d<\/a><\/li>\r\n\t<li><a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/techdoc\/ref\/printopt.html\"><tt>print<\/tt> command<\/a>.<\/li>\r\n<\/ul>\r\n<\/div>\r\n<a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2565#respond\">Comments?<\/a>\r\n\r\n<script>\/\/ <![CDATA[\r\nfunction grabCode_0fd296b61d37461f8d93b69dfeefd8e8() {\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='0fd296b61d37461f8d93b69dfeefd8e8 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 0fd296b61d37461f8d93b69dfeefd8e8';\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        author = 'Brett Shoelson';\r\n        copyright = 'Copyright 2010 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('\r\n\r\n\r\n\r\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>\r\n\r\n\r\n\r\n\r\n\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }\r\n\/\/ ]]><\/script>\r\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\"><a><span style=\"font-size: x-small; font-style: italic;\">Get\r\nthe MATLAB code\r\n<noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\r\nPublished with MATLAB\u00ae 7.10\r\n\r\n<\/div>\r\n<!--\r\n0fd296b61d37461f8d93b69dfeefd8e8 ##### SOURCE BEGIN #####\r\n%% Creating and Exporting Publication-Quality Graphics\r\n%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911 Brett>'s Pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/23629-export-fig export_fig>, by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/29192 Oliver Woodford>.\r\n%\r\n%\r\n% Frequently, when I'm bantering about MATLAB at cocktail parties, the\r\n% question of how to create \"publication-quality\" graphics from MATLAB\r\n% arises. Many of you do great work using our tools, but are stymied when\r\n% it comes time to publish your results with high-end plots and figures.\r\n% To address these questions, I've started  maintaining a list of resources\r\n% that facilitate the creation of such graphics; Oliver's \"export_fig\" has\r\n% recently found its way onto my list.\r\n\r\n%% Oliver's contribution\r\n% Function |export_fig| is described on the File Exchange with this verbiage:\r\n%\r\n% This function saves a figure or single axes to one or more vector and\/or bitmap file formats, and\/or outputs a rasterized version to the workspace, with the following properties:\r\n%\r\n% * Figure\/axes reproduced as it appears on screen\r\n% * Cropped borders (optional)\r\n% * Embedded fonts (vector formats)\r\n% * Improved line and grid line styles\r\n% * Anti-aliased graphics (bitmap formats)\r\n% * Render images at native resolution (optional for bitmap formats)\r\n% * Transparent background supported (pdf, eps, png)\r\n% * Semi-transparent patch objects supported (png only)\r\n% * RGB, CMYK or grayscale output (CMYK only with pdf, eps, tiff)\r\n% * Variable image compression, including lossless (pdf, eps, jpg)\r\n% * Optionally append to file (pdf only)\r\n% * Vector formats: pdf, eps\r\n% * Bitmap formats: png, tif, jpg, bmp, export to workspace\r\n%\r\n% This function is especially suited to exporting figures for use in\r\n% publications and presentations, because of the high quality and portability of media produced.\r\n\r\n%%\r\n%\r\n% <<https:\/\/blogs.mathworks.com\/pick\/..\/images\/pick\/exportfigscreencap.jpg>>\r\n%\r\n\r\n%%\r\n% There are several things I particularly like about |export_fig|. (Others\r\n% have liked it, too; as of this writing, the entry was downloaded 737\r\n% times in the last month alone, and has an average user rating of 4.9 out\r\n% of 5, from 28 ratings!) The code is well-implemented, and appears to be\r\n% pretty robust. Also, the function is nicely documented (though it might be\r\n% useful to include an example or two).\r\n%\r\n% I also like how responsive Oliver has been in responding to queries and\r\n% suggestions. The file has been updated 21 times (!) since it was\r\n% originally posted in April, 2009, largely in response to user suggestions\r\n% and bug reports. That's responsive, and great use of the MATLAB Central\r\n% File Exchange!\r\n\r\n%% Other useful resources and links\r\n% MathWorker <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/3024 Ben Hinkle> wrote a two-part <https:\/\/www.mathworks.com\/company\/newsletters.htmlsubscribe_home.html MATLAB Digest> article many\r\n% years ago that has stood the test of time. In <https:\/\/www.mathworks.com\/company\/newsletters.htmldigest\/june00\/export\/ part 1>, he\r\n% discussed the issue, and introduced his\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/727-exportfig % exportfig>, with which one could control basic graphic properties and\r\n% create EPS figures. In <https:\/\/www.mathworks.com\/company\/newsletters.htmldigest\/december00\/export.html part 2>, Ben also provided some additional\r\n% functions, including the ability to preview or restore figures.\r\n\r\n%%\r\n% Fellow Pick-of-the-Week blogger <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007 Jiro> guest blogged on <https:\/\/blogs.mathworks.com\/loren\/ \"Loren on the Art of MATLAB\">\r\n% about how to <https:\/\/blogs.mathworks.com\/loren\/2007\/12\/11\/making-pretty-graphs\/ \"make graphs pretty\">.\r\n\r\n%%\r\n% Finally, these doc pages might be useful in this regard:\r\n%\r\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2010a\/techdoc\/creating_plots\/f3-103236.html \u00e2\u20ac\u0153Choosing a Graphics Format\u00e2\u20ac\ufffd>\r\n% * <https:\/\/www.mathworks.com\/help\/releases\/R2010a\/techdoc\/ref\/printopt.html |print| command>.\r\n\r\n%%\r\n% You might also check out Oliver's <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/23604-fix-lines fix_lines> submission for \"Fixing Postscript\r\n% Lines,\" <https:\/\/blogs.mathworks.com\/pick\/2010\/01\/15\/fixing-postscript-lines\/ featured> as a Pick of the Week back in January.\r\n\r\n%%\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2565#respond Comments?>\r\n##### SOURCE END ##### 0fd296b61d37461f8d93b69dfeefd8e8\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n\r\nBrett's Pick this week is export_fig, by Oliver Woodford.\r\n\r\nFrequently, when I'm bantering about MATLAB at cocktail parties, the question of how to create \"publication-quality\" graphics\r\nfrom... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2010\/05\/28\/creating-and-exporting-publication-quality-graphics\/\">read more >><\/a><\/p>","protected":false},"author":34,"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\/2565"}],"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\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2565"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2565\/revisions"}],"predecessor-version":[{"id":7321,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2565\/revisions\/7321"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}