简体   繁体   English

将包含MATLAB中子图的图形以精确尺寸导出为pdf

[英]Export figure containing subplots in MATLAB to pdf in exact dimensions

I have been struggling with this issue for quite a long time. 我在这个问题上苦苦挣扎了很长时间。 I have the following code:- 我有以下代码:-

    y = -16.55 : 0.01: 16.55;
    xpos = 10.5361 * cos(y/10.5361) * (pi/20);
    x = [-xpos,xpos];
    y = [y,-y];

    a1 = subplot(1,4,1);
    fill(x,y,'r');

    a2 = subplot(1,4,2);
    fill(x,y,'g');

    a3 = subplot(1,4,3);
    fill(x,y,'o');

    a4 = subplot(1,4,4);
    fill(x,y,'w');

    set(a1,'Units','centimeters','Position',[0 0 5 36]);
    set(a2,'Units','centimeters','Position',[5.5 0 5 36]);
    set(a3,'Units','centimeters','Position',[11 0 5 36]);
    set(a4,'Units','centimeters','Position',[16.5 0 5 36]);

This code produces 4 subplots. 此代码产生4个子图。 Now I need to export the whole figure (not just what appears on the screen) in exact dimensions (as pointed by the data cursor in the figure) to pdf from MATLAB. 现在,我需要将整个图形(不仅仅是屏幕上显示的图形)以精确的尺寸(由图形中的数据光标指向)导出到MATLAB中的pdf。 Please suggest how to do. 请提出建议。 I went through the following link but not of much help:- 我浏览了以下链接,但没有太大帮助:-

MATLAB: print a figure to pdf as the figure shown in the MATLAB MATLAB:将图形打印为pdf,如MATLAB中所示

Please suggest a solution. 请提出解决方案。

Exporting figures in matlab can be very painful... For me it was until i discovered this: 在matlab中导出数字可能非常痛苦...对我而言,直到我发现了这一点:

http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig

It exports as pdf or eps, the whole figure under display (it removes blank borders)... Have you tried it? 它以pdf或eps格式导出​​,整个显示状态下的图形(删除空白边框)...您尝试过吗?

export_fig file_name.pdf and it is done! export_fig file_name.pdf完成了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM