tag:blogger.com,1999:blog-8218335746174572895.post7865106927826513671..comments2023-09-22T06:21:28.926-04:00Comments on Jason's Log: On importing MatLAB figures into papers and presentationsJasonPhttp://www.blogger.com/profile/11833243938676843398noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-8218335746174572895.post-67087860345750154842011-01-26T09:50:48.926-05:002011-01-26T09:50:48.926-05:00I mostly use LaTeX to create report, parpers or pr...I mostly use LaTeX to create report, parpers or presentations (beamer).<br />So naturally, my favorite image format for Matlab figures are eps (compiling with latex command) and pdf (compiling with pdflatex command).<br />I always output my figures to eps files and use epstopdf if needed.<br />If I have to do Word-like documents, I still use eps files under OpenOffice.org and things are almost ok (it may eats a lot of cpu at times).<br /><br />On the Matlab side, I far as I've tested things, I do the following:<br />1) generate/display a figure (always scripts) on screen,<br /><br />2) resize it,<br />It can be done manually, or automatically using:<br /> pos=get(fid, 'position');<br /> set(fid, 'Position', [pos(1:2), width, height]);<br /><br />3) set figure's the "paper position mode" to auto in order to get an eps file that will look like what is displayed on screen (but this is not really accurate...):<br /> set(gcf,'paperpositionmode','auto');<br /><br />4) call a homebrew function called "fig_print". Schematically (when args parsed & string to eval constructed) it does the following:<br /> eval(['print -f', num2str(fid), ' -d', lower(format), ' -noui -painters -adobecset -r', num2str(resolution), ' ', filename]);<br />For example, for figure #3, 'eps' format, 300dpi resolution and filename '/tmp/fig_print-test.eps' (default settings), it gives the following:<br /> print -f3 -deps -noui -painters -adobecset -r300 /tmp/fig_print-test.eps<br />Note that I don't use -loose option since it uselessly increases the eps bounding box (adds extra margins that I don't wish to get in my documents).<br />The resolution shouldn't have any effect since eps is vector format, but it does indeed and modifies, for example, the radius of plot dots (I assume their raduis is set as a number of dots, so that's quite logical...)<br /><br /><br />Pros and cons of this method:<br /> + that's a way to control graphics output,<br /> + when all is well tuned, eps figure are really nice for both TeX and Word-like docs,<br /> + things can be almost automated (even resizing is called from my figures scripts),<br /><br /> - I sometimes have issues with legends and text in it that can exceed the legend box,<br /> - I have to resize the figure smaller in order to increase font size into resulting eps figures,<br /> - axes ticks on screen won't match those I will obtain in the eps file,<br /> - it's painful to redo figures with a different plot/text sizes ratio (playing with figure size, cf. 2)...)Unknownhttps://www.blogger.com/profile/11393210829872938771noreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-87550674609887626302011-01-26T09:49:30.503-05:002011-01-26T09:49:30.503-05:00This comment has been removed by the author.Unknownhttps://www.blogger.com/profile/11393210829872938771noreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-67926215392902301412009-08-14T12:37:33.892-04:002009-08-14T12:37:33.892-04:00I use print -dpng -r90. This makes plots which ha...I use print -dpng -r90. This makes plots which have readable fonts when inserted into Word and PowerPoint. -- JohnUnknownhttps://www.blogger.com/profile/02249955867304576790noreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-29803704986710356972008-10-11T04:44:00.000-04:002008-10-11T04:44:00.000-04:00Basically, you want work in centimeters on the scr...Basically, you want work in centimeters on the screen:<BR/><BR/>set(gcf, 'Units', 'centimeter');<BR/><BR/>and then put the figure to whatever size you want in centimeters and set it to print at that size as well:<BR/><BR/>set(gcf, 'Position', [10 10 XX YY], 'PaperPosition', [30 30 XX YY]);<BR/><BR/>Now, put your axes in specific places also with a specific size and set the axes limits to match the size of the axes<BR/><BR/>axes('Units', 'centimeter', 'Position', [0.5 0.5 XXa YYa], 'XLim', [0 XXa], 'YLim', [0 YYa]);<BR/><BR/>Finally, draw a 1 cm line<BR/><BR/>line([1 2], [1 1]);<BR/><BR/>I think that should do you.<BR/><BR/>OpherOpher Donchinhttps://www.blogger.com/profile/04922496263220118414noreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-34278474533427267732008-10-08T13:57:00.000-04:002008-10-08T13:57:00.000-04:00I am interested in making several figures using th...I am interested in making several figures using the same unit (i.e. 1 unit = 1 cm on the screen), before exporting them, but I don't know how. Maybe you have an ideea that I might try.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-50779805540612130112008-08-15T18:44:00.000-04:002008-08-15T18:44:00.000-04:00Ken:I've updated this post with what I've ...Ken:<BR/><BR/>I've updated this post with what I've found about exporting (importing) figures with shading in them. You can find the new material at the end of the post. Let me know if this helps, or if you need more information.<BR/><BR/>Florist:<BR/><BR/>I agree, about using scripts to modify the property values of the handle graphics directly. Also, there's no GUI way that I've found to specify the -loose option when printing/exporting a figure to an eps file. On the other hand, I don't know of a command-line way to specify the "Keep screen limits and ticks" option, so I'm forced to go the GUI route for that (FigureWindow > File > Page Setup > Axes and Figure). So, the method I've settled on for exporting as png/eps, but with matching screensize and with loose bounding box, is:<BR/><BR/>% ----------------------------------------------- %<BR/>% (Select one of the following, as appropriate:)<BR/><BR/>cur_axes = gca;<BR/><BR/>% OR<BR/><BR/>% This includes legends as well, but need to do this if figure windows have subplots (or multiple axes).<BR/>axobj = findobj('type', 'axes'); <BR/>for i = 1:length(axobj) <BR/> cur_axes = axobj(i); <BR/><BR/>% OR <BR/><BR/>figobj = findobj('type', 'figure');<BR/>for i = 1:length(figobj)<BR/> cur_axes = get(figobj(i), 'CurrentAxes'); <BR/>% ------------------------------------------------ %<BR/><BR/> x_lab = get(cur_axes, 'XLabel');<BR/> y_lab = get(cur_axes, 'YLabel');<BR/> z_lab = get(cur_axes, 'ZLabel');<BR/> titl = get(cur_axes, 'Title');<BR/> <BR/> set(cur_axes, 'linewidth', 0.5);<BR/> set(cur_axes, 'yminortick', 'on', 'xminortick', 'on')<BR/> set(cur_axes, 'FontUnits', 'points', 'Fontsize', 11, 'Fontweight', 'normal');<BR/> set(x_lab, 'FontUnits', 'points', 'Fontsize', 14, 'Fontweight', 'normal');<BR/> set(y_lab, 'FontUnits', 'points', 'Fontsize', 14, 'Fontweight', 'normal');<BR/> set(z_lab, 'FontUnits', 'points', 'Fontsize', 14, 'Fontweight', 'normal');<BR/> set(titl, 'FontUnits', 'points', 'Fontsize', 11, 'Fontweight', 'normal');<BR/>end<BR/>lobj = findobj('tag', 'legend');<BR/>set(lobj, 'fontsize', 10)<BR/><BR/><BR/>Then go the GUI route to specify the "Keep screen limits and ticks" and "Use screen size" options (although the latter is equivalent to setting the figure's PaperPositionMode property value to "auto").<BR/><BR/><BR/>And then either GUI-export the figure as a png, or use the command:<BR/>print -deps2 -loose [filename]JasonPhttps://www.blogger.com/profile/11833243938676843398noreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-16679500387900130762008-08-15T09:08:00.000-04:002008-08-15T09:08:00.000-04:00I have been asked to help someone (they were despe...I have been asked to help someone (they were desperate) to create a graph that uses shading and to paste it into a Word document so that the Word document can then also be converted to pdf, with both the word and the pdf suitable for display on the net. Is this possible? <BR/>I have access to Mathematica and Matlab, and I regularly use LaTeX (with PSTricks if needed).<BR/>I am happy to do some reading but I am unsure of what to read. Can you help?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-89035904689832952292008-07-07T23:20:00.000-04:002008-07-07T23:20:00.000-04:00I find the best method to output high quality file...I find the best method to output high quality files is to print to a file. I use png for Word and eps (-deps or -depsc) for latex. You can do it in a script, too.<BR/> <BR/>e.g. to save figure 1 at 600 dpi to a png:<BR/>figure(1)<BR/>plot(rand(1,10))<BR/>print('-f1', '-r600', '-dpng', 'test.png');Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-64131125938749381112008-04-11T12:56:00.000-04:002008-04-11T12:56:00.000-04:00I don't think EPS technically has a resolution. It...I don't think EPS technically has a resolution. It is just a text file that has Postscript commands, and therefore can be rendered in any resolution. But I might be wrong here. <BR/><BR/>I find that fiddling with the properties of the gcf handle gives you much better control over the matlab figure and can be done via scripts, much easier than having to tweak individual figures. For example, to render plots in two column mode:<BR/><BR/>set(gcf,'PaperPositionMode','manual');<BR/>set(gcf,'PaperUnits','inches');<BR/>set(gcf,'PaperPosition',[0 0 3 7.5]);Floristhttps://www.blogger.com/profile/16306050498392199602noreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-61722840140650718122008-02-03T19:27:00.000-05:002008-02-03T19:27:00.000-05:00Ahha. I think that I was trying to say "*nix-users...Ahha. I think that I was trying to say "*nix-users". Thanks for the clarification. To be more generalized, it should be "command-line lovers". :)<BR/><BR/>So what about you? (I mean the OS you use on your own laptop instead of the fancy "super-computer" at your workplace.)Jhttps://www.blogger.com/profile/14877502058173293342noreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-67578779695002231602008-02-01T23:38:00.000-05:002008-02-01T23:38:00.000-05:00J: Correct, except that we're more *nix-users tha...J: Correct, except that we're more *nix-users than Mac-users (although there are plenty of those out there, too). Anything with a command prompt, basically. We do use Windows machines a lot, too --- simply because they're so ubiquitous.JasonPhttps://www.blogger.com/profile/11833243938676843398noreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-34342703810606128662008-01-29T18:37:00.000-05:002008-01-29T18:37:00.000-05:00Some of MY stereotypical impression of an engineer...Some of MY stereotypical impression of an engineer are: Mac-user, MATLAB-lover, open-source software-lover, and MS-software-despiser... :)<BR/><BR/>Plus, I heard (not sure if it is correct) that Mac OS is good for graphic design.Jhttps://www.blogger.com/profile/14877502058173293342noreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-26553194770987142872008-01-29T14:32:00.000-05:002008-01-29T14:32:00.000-05:00What made you think that?What made you think that?JasonPhttps://www.blogger.com/profile/11833243938676843398noreply@blogger.comtag:blogger.com,1999:blog-8218335746174572895.post-57660066408292419492008-01-28T18:16:00.000-05:002008-01-28T18:16:00.000-05:00Thought you're a Mac-user...Thought you're a Mac-user...Jhttps://www.blogger.com/profile/14877502058173293342noreply@blogger.com