Font size problem for a Matlab figure in a template - matlab

I know this is a topic that is closed but I am struggling to put a MATLAB figure in a beamer template with the adequate font size.
I started to use the Export setup of MATLAB to adjust the dimensions of my figure and also the font size which is 12 pts :
This size is chosen because the font size of a frame title appears to be this value.
Then, I save it as an eps file and I check the dimensions with Inkscape : everything seems to be correct.
But when loading it in my beamer template, the font size seems to not be adequate anymore (see the difference between the font size of the title and the font size of the figure):
My coding is very basic since I am just loading my eps file in LaTex document after conversion to PDF \usepackage{epstopdf} :
\includegraphics[width=1 \linewidth]{pic/test.eps}
Is there a simple way to make the font size of the figure similar to the font size of the title ?
Thank you for your help,

Related

Write Large Image as PDF in MATLAB

I am trying to write a large image to PDF (141"x24" at 300 DPI, so 42300 pixels x 7200 pixels). I can write the image as a png without a problem using imwrite(). However, imwrite() does not provide PDF as an output option. So, the alternatives I have seen online all do something like this:
pdffig = figure;
set(pdffig,'Units','Inches','Position',[0 0 141 24],'PaperSize',[141 24]);
pdfaxs = axes;
imshow(Im,'Parent',pdfaxs);
print(pdffig,'largeimage.pdf','-dpdf');
This code is creating a figure, setting some properties to make the figure 141x24 inches in size, showing the image on the figure axis, and then printing the figure contents to pdf.
Unfortunately, what happens is that the figure is resized to fit my screen when imshow() is called and then the printed pdf will have a small version of the image in the center of a large white pdf. What I actually want is for the image to take up the entire 141"x24" pdf. I have tried rearranging when the window size is set and when imshow() is called, but that doesn't help. Note that this works if the desired PDF size fits on my screen (e.g. if I was printing a 12"x12" PDF).
Any suggestions are appreciated!

Output high-resolution figure from Matlab with full picture

I want to output a high-resolution figure from Matlab.
I tried to "save as pic.eps". But when I insert this picture in latex, it seems that the picture is not "real eps" in the sense that I can tell that the resolution is not enough.
I also tried to "save as pic.pdf". The resolution meets my demand, but the pic is cropped, as it is too large.
Then I used
print -depsc -tiff -r300 -painters pic.eps
This gives me the high-resolution full picture, but some of the dashed lines in the original picture disappeared. I have tried many other cases and still couldn't find the right way to solve my problem. Any suggestions are highly appreciated
I'd try to save eps in vector format, or use a vector only format such as .svg.
For example,
print -depsc2 -painters test.eps
These are the vector graphics supported formats according to the current documentation:
Option Vector Graphics Format File Extension
'-dpdf' Full page Portable Document Format (PDF) color .pdf
'-deps' Encapsulated PostScript (EPS) Level 3 black and white .eps
'-depsc' Encapsulated PostScript (EPS) Level 3 color .eps
'-deps2' Encapsulated PostScript (EPS) Level 2 black and white .eps
'-depsc2' Encapsulated PostScript (EPS) Level 2 color .eps
'-dmeta' Enhanced Metafile (Windows® only) .emf
'-dsvg' SVG (Scalable Vector Graphics) .svg
'-dps' Full-page PostScript (PS) Level 3 black and white .ps
'-dpsc' Full-page PostScript (PS) Level 3 color .ps
'-dps2' Full-page PostScript (PS) Level 2 black and white .ps
'-dpsc2' Full-page PostScript (PS) Level 2 color .ps
you'll also have to use the '-painters' renderer when saving vector graphics files. If you save to a vector graphics file and if the figure RendererMode property is set to 'auto', then print automatically attempts to use the Painters renderer. If you want to ensure that your output format is a true vector graphics file, then specify the Painters renderer. For example:
print('-painters','-deps','myVectorFile')
this command in question may come from the following link
After removing -tiff, my issue of missing one line was fixed (even though I don't understand what is '-tiff' for)

Matlab figure size formatting for Word

I'm trying to create MATLAB figures to put into a paper. The paper has very specific sizing instructions for figures that I'm having trouble matching in MATLAB. The figures need to be no greater than 3.5" width, >300 DPI, with 8pt font.
In my code, I use the following to try to set the parameters:
set(gcf,'PaperUnits','inches');
set(gcf,'PaperPosition',[0 0 3.5 3.5]);
xlabel('x-axis label','FontSize',8);ylabel('y-axis label','FontSize',8);
set(gca,'FontSize',8);
print('-djpeg','-r300','filename.jpg')
This should be giving me a 300 DPI, 3.5"x3.5" JPEG image with an 8pt font size. However, when I import the image into Word, it becomes 6.5" x 6.5" and the font size is larger than Word's 8pt font. Even if I resize the image, the font size is still too large, though it should maintain the same DPI. Are the FontSize and PaperPosition parameters not working as I expect they should or is Word doing something strange for importing?
The font size issue was caused due to differing fonts used in MATLAB and Word. Once I learned about set(gca,'FontName'), the font size seemed to be correct when the image was manually resized to 3.5" x 3.5".
The image size issue seemed to be related to saving it as a JPEG. Once I swapped to PNG, the image was the correct size by default. Looking into the JPEG properties, it had the correct number of pixels for a DPI of 300 at 3.5", the sole issue was that it would have to be manually resized. Thanks for the comments that led me to finding a solution.

Publish to Latex from Matlab

While producing Latex output from Matlab, I used the following in
command window:
publish('filename.m',struct('format','latex','showCode',false, ...
'maxWidth',3,'outputDir','Desktop'));
The latex file produced has graphics width always 4in. Even though I
changed the maxWidth to 5, 6, 1000 etc, the graphics width remains
always the same: 4in.
How can I vary the graphics width in latex directly from Matlab?
It looks like maxWidth option affects only pixel images, like png, bmp etc. It affects actual image size, so with maxWidth set to 3, you will get images with maximum 3 pixel width. It's not controlled by format itself, like width argument in html or latex. PUBLISH function uses XML as the intermediate format and I believe this is the problem of current XML schema design.
With latex format PUBLISH by default uses epsc2 print driver and produces vector image in EPS format. So maxWidth is simply ignored. If you use ...'imageFormat','png',... in publish call you notice that the size of output png file changes in accordance with maxWidth. Anyway the size of the image in tex document will be 4in (with bad image resolution in case of low maxWidth) as set in the default stylesheet for latex.
Looks like there is no way to change this behavior in PUBLISH.
You can modify the xml stylesheet (matlabroot/toolbox/matlab/codetools/private/mxdoom2latex.xls).
Check for those lines:
<xsl:template match="img">
\includegraphics [width=4in]{<xsl:value-of select="#src"/>}
</xsl:template>
Copy this file, modify and specify the new file with stylesheet option.
Or simply change the width argument in the output .tex file(s).

Increasing text size in MuPAD?

MuPAD's text output is ridiculously small for me to read, and although every time I adjust the size, it does not seem to save my preferences. Is there any way to set MuPAD's text size so that it stays as I would like it to? Thanks! btw I am on a mac.
You can adjust the font size in the preferences menu:
matlab→Preferences→Notebook→Default Formats...
You can also change the text size as shown here and switch the pagination as shown here