How to save MATLAB figure as JPEG using saveas() without the image coming off badly?

前端 未结 3 1085
[愿得一人]
[愿得一人] 2020-12-30 00:45

In a MATLAB function I am writing, I am generating a figure. The figure is displayed when the function is executed. I need to save the figure as a JPEG image. To do that, I

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 01:20

    Just use a lossless scalable format like EPS, see last line in the snippet below :)

    h1=figure % create figure
    plot(t,Data,'r');
    legend('Myfunction');
    
    % Create title with required font size
    title({'Variance vs distance'},'LineWidth',4,'FontSize',18,...
    'FontName','Droid Sans');
    
    % Create xlabel with required font size
    xlabel({'Distance (cm)'},'FontSize',14,...
    'FontName','DejaVu Sans');
    
    % Create ylabel with required font size
    ylabel({'Variance of sobel gradients'},'FontSize',14,...
    'FontName','DejaVu Sans');
    
    print(h1,'-depsc','autofocus.eps') % print figure to a file
    

    I cannot attach an EPS file here though, not supported, but its scalable and can be put in word processors or Latex without worrying about bad resolution.

提交回复
热议问题