?
Solved

Multiple figure in matlab

Posted on 2011-09-08
7
Medium Priority
?
1,010 Views
Last Modified: 2016-03-02
I created 4 different figures and i load it to a Matlab (4 figures in one page).Is it possible to export this page to png format ? (i need 4 graph per page)
0
Comment
Question by:Tom3333
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 

Author Comment

by:Tom3333
ID: 36510171
No respond yet??
0
 
LVL 15

Expert Comment

by:yuk99
ID: 36511964
One option is to use subplot function while generating the figures as individual axes;

subplot(2,2,1)
% code for figure 1
% ...
subplot(2,2,2)
% code for figure 2
% ...
subplot(2,2,3)
% code for figure 3
% ...
subplot(2,2,4)
% code for figure 4
% ...

Open in new window

0
 
LVL 15

Expert Comment

by:yuk99
ID: 36512036
There are many File Exchange submissions related to your question. Some are just a better versions of SUBPLOT (used while creating the figures).

http://www.mathworks.com/matlabcentral/fileexchange/20003-panel
http://www.mathworks.com/matlabcentral/fileexchange/3696-subaxis-subplot

Others can combine separately generated figures into one figure.

http://www.mathworks.com/matlabcentral/fileexchange/3939-import-fig-file-to-axes
http://www.mathworks.com/matlabcentral/fileexchange/27713-montagefigures

Another one is SubplotPPT to save multiple figures to a single Powerpoint slide:
http://www.mathworks.com/matlabcentral/fileexchange/20949-subplotppt
You can then arrange it as you want and save as PNG.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:Tom3333
ID: 36513311
without  the use of subplot  (just to have 4 figure in one page) is it possible to export it?
0
 
LVL 15

Expert Comment

by:yuk99
ID: 36513610
No, you can export only one figure per page. If you want to put multiple figure on one page, you have to put them into one figure as axes. You can use SUBPLOT or arrange the axes manually with 'Position' property. Other alternatives I put above.

Please describe your problem in more details. How do you generate the figures? Why don't you like the SUBPLOT option?

You can also save multiple figures into one PDF or multipage TIF file, but they will be one figure per page. I think it's not what you want.
0
 
LVL 5

Expert Comment

by:Kenneth Brown
ID: 36897988
You can sort of cheat by using printscreen button to save to the clipboard a bitmap of the screen image while youve got any plot or subplot displayed, then manipulate these and save in png format using your graphics editor of choice, eg PSP etc.
0
 
LVL 15

Accepted Solution

by:
yuk99 earned 200 total points
ID: 36904448
Tom3333,
Are you still interested in answer? Do you need automated solution in MATLAB?

The main problems with SUBPLOT are the following:
1. If you have multiple axes on even one of your figures. They will have to managed separately on subplot context, since subplot function actually returns only one axis. Sometime it can be hard.
2. Colormap has to be the same for all figures.
3. Large gaps between figures.

One way to avoid it:
1) save individual figures as PNG files
2) show all the images on one figure
3) print the figure to PNG

Here is the code after you save the individual figures:
ax(1) = axes('units','normalized','position',[0 0.5 0.5 0.5]);
ax(2) = axes('units','normalized','position',[0.5 0.5 0.5 0.5]);
ax(3) = axes('units','normalized','position',[0 0 0.5 0.5]);
ax(4) = axes('units','normalized','position',[0.5 0 0.5 0.5]);
set(ax,'visible','off')
imshow('fig1.png','parent',ax(1))
imshow('fig2.png','parent',ax(2))
imshow('fig3.png','parent',ax(3))
imshow('fig4.png','parent',ax(4))
print -dpng -r600 4figures.png

Open in new window

You need to set a good resolution in print command or appropriate figure size with set(gcf,'units','pixels','position',[0 0 width height]) before print.
IMSHOW requires Image Processing Toolbox. Can be substituted with IMAGE or IMAGESC, but need some additional steps.

If all your figures have the same size, here is the easier solution:
x = cell(2);
x{1,1} = imread('fig1.png');
x{1,2} = imread('fig2.png');
x{2,1} = imread('fig3.png');
x{2,2} = imread('fig4.png');
y = cell2mat(x); % will return an error if figures  size is different
imwrite(y,'4figures.png')

Open in new window

0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question