简体   繁体   中英

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. 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. 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

Please suggest a solution.

Exporting figures in matlab can be very painful... For me it was until i discovered this:

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?

export_fig file_name.pdf and it is done!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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