Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:26:00+00:00 2026-05-23T14:26:00+00:00

I’m currently creating my figures in matlab to embed themvia latex into a pdf

  • 0

I’m currently creating my figures in matlab to embed themvia latex into a pdf for later printing. I save the figures and save them via the script export_fig! Now I wonder which is the best way to go:

  • Which size of the matlab figure window to chose
  • Which -m option to take for the script? It will change the resolution and the size of the image…

I’m wondering about those points in regards to the following two points:

  1. When chosing the figure-size bigger, there are more tickmarks shown and the single point markers are better visible
  2. When using a small figure and using a big -m option, I still have only some tickmarks
  3. When I generate a image which is quite huge (e.g. resolution 300 and still 2000*2000px) and than embed it into the document: Does this than look ugly? Will this be embedded in a nice scaling mode or is it the same ugliness as if you upload a 1000*1000px image onto a homepage and embed it via the widht and height tags in html -> the browser displays it quite ugly because the browser doesn’t do a real resize. So it looks unsharp and ugly.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:26:01+00:00Added an answer on May 23, 2026 at 2:26 pm

    The MATLAB plots are internally described as vector graphics, and PDF files are also described using vector graphics. Rendering the plot to a raster format is a bad idea, because you end up having to choose resolution and end up with bigger files.

    Just save the plot to EPS format, which can be directly embedded into a PDF file using latex. I usually save my MATLAB plots for publication using:

    saveas(gcf, 'plot.eps', 'epsc');
    

    and embed them directly into my latex file using:

    \includegraphics[width=0.7\linewidth]{plot.eps}
    

    Then, you only need to choose the proportion of the line the image is to take (in this case, 70%).

    Edit: IrfanView and others (XnView) don’t display EPS very well. You can open them in Adobe Illustrator to get a better preview of what it looks like. I always insert my plots this way and they always look exactly the same in the PDF as in MATLAB.

    One bonus you also get with EPS is that you can actually specify a font size so that the text is readable even when you resize the image in the document.

    As for the number of ticks, you can look at the axes properties in the MATLAB documentation. In particular, the XTick and YTick properties are very useful manually controlling how many ticks appear no matter what the window resolution is.

    Edit (again): If you render the image to a raster format (such as PNG), it is preferable to choose the exact same resolution as the one used in the document. Rendering a large image (by using a big window size) and making it small in the PDF will yield bad results mainly because the size of the text will scale directly with the size of the image. Rendering a small image will obviously make for a very bad effect because of stretching.

    That is why you should use a vector image format. However, the default MATLAB settings for figures produce some of the same problems as raster images: text size is not specified as a font size and the number of ticks varies with the window size.

    To produce optimal plots in the final render, follow the given steps:

    1. Set the figure’s font size to a decent setting (e.g. 11pt)
    2. Render the plot
    3. Decide on number of ticks to get a good effect and set the ticks manually
    4. Render the image to color EPS

    In MATLAB code, this should look somewhat like the following:

    function [] = nice_figure ( render )
        %
          % invisible figure, good for batch renders.
        f = figure('Visible', 'Off');
          % make plots look nice in output PDF.
        set(f, ...
            'DefaultAxesFontSize', 11, ...
            'DefaultAxesLineWidth', 0.7, ...
            'DefaultLineLineWidth', 0.8, ...
            'DefaultPatchLineWidth', 0.7);
          % actual plot to render.
        a = axes('Parent', f);
          % show whatever it is we need to show.
        render(a);
          % save file.
        saveas(f, 'plot.eps', 'epsc');
          % collect garbarge.
        close(f);
    end
    

    Then, you can draw some fancy plot using:

    function [] = some_line_plot ( a )
        %
          % render data.
        x = -3 : 0.001 : +3;
        y = expm1(x) - x - x.^2;
        plot(a, x, y, 'g:');
        title('f(x)=e^x-1-x-x^2');
        xlabel('x');
        ylabel('f(x)');
          % force use of 'n' ticks.
        n = 5;
        xlimit = get(a, 'XLim');
        ylimit = get(a, 'YLim');
        xticks = linspace(xlimit(1), xlimit(2), n);
        yticks = linspace(ylimit(1), ylimit(2), n);
        set(a, 'XTick', xticks);
        set(a, 'YTick', yticks);
    end
    

    And render the final output using:

    nice_figure(@some_line_plot);
    

    With such code, you don’t need to worry about the window size at all. Notice that I haven’t even showed the window for you to play with its size. Using this code, I always get beautiful output and small EPS and PDF file sizes (much smaller than when using PNG).

    The only thing this solution does not address is adding more ticks when the plot is made larger in the latex code, but that can’t be done anyways.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.