How to load a .fig file as small sub-figure in an existing one? - matlab-figure

I want to create one figure that shows two plots. But not as a normal subplot(1,2,1) that will create two "parallel" panels. Instead I want one figure to be small and located in a corner of another one.
Let's assume the main figure is something as simple as:
h1=fplot(#(x) 2*x +1.4*x^2 -0.8*x^3,[0 1]);
hold on;
h2=fplot(#(x) 0.5*x +1.8*x^2 -1.2*x^3,[0 1]);
legend('line 1','line 2','location','southeast');
One more complication is: the second figure (the small one I want to be in the corner) is saved as "external" .fig file (I can easily import it with open example.fig, but it obviously opens as a new window).

Related

Open .fig file and delete some of the plot entries-Matlab

I have the following image stored as f7.fig. I want to open it again and delete all the other entries except the first (red), second (blue) and last(cyan). I want also to delete them from the legend. Is this possible?
An easy interactive approach would be like this:
savefig(h, 'somefig.fig`); % Save figure
% Close the figure ...
openfig('somefig.fig'); % Open figure
% Click on the curves you wanted to delete ....
delete(gco); % delete object -> this takes care of the legend too
% Click on the curves you wanted to delete ....
delete(gco);
% so on...
This approach here is also an alternative.

Animating XY Line in TecPlot

I'm an environmental engineer using TecPlot to plot come charts with some input data, let me explain my problem.
I'm studying the evolution of a river bed with a Fortran code which I wrote. As a output the code gives a detailed stratigraphy going some centimeters under the soils surface. Basically the output file looks like this:
0.03500000000 -0.18093000000 -0.17093000000 -0.16093000000 -0.15093000000 ...
0.10500000000 -0.18100000000 -0.17100000000 -0.16100000000 -0.15100000000 ...
0.17500000000 -0.18107000000 -0.17107000000 -0.16107000000 -0.15107000000 ...
0.24500000000 ...
and so on.
The first column is the x variable (horizontal evolution) and has 200 data.
The other columns are the evolution on the vertical coordinate.
So basically for each line we have, starting from the second colon, an horizontal line drawn thanks to 400 values.
For example if I plot the entire first column with the entire first row what I get is just a line on the plot.
For each time step my Fortran code create an output file which gives a plot with all the substrate lines.
What I want to do, and I really don't know how to do it, is animating this plots in order to have, for each time step of the animation, the ENTIRE plot with ALL THE LINES.
What I've done in TecPlot so far is:
1) import all the output files
2) put them in the XY Line plot of TecPlot using one zone for each output file I have (file 1 -> 1:ZONE001, file 2 -> 2:ZONE001, file 3 -> 3:ZONE001 and so on)
3) trying to turn them into contour plot (no results)
3.2) trying to animate them with XY Line plot animation (too bad, it animates every single line...)
I hope that I've been enough thorough to let you helping me.
I would appreciate each contribution and I thank You for each -even short, small- answer.
Best regards
Assuming you have already loaded the file, and have multiple zones. you can animate the mappings by Animate -> Mappings.., As far as
trying to animate them with XY Line plot animation (too bad, it animates every single line...)
is concerned, you need Map Skip value more than 1, to skip the mappings (lines). The animation can be saved as video or image sequences from the same dialogue box, by pressing the small video button besides the play rewind and forward buttons enter image description here

VTK display multiple images

Does someone knows how to display multiple images using ActiViz or VTK?
I have a RenderWindowControl, I would like to either display all the images like in a list in there or add multiple RenderWindowControls to display the multiple images..
Thanks!
You have some choices, for the task of visualize multiple images. I hope that at least one of them represents what you want to achieve:
1- Using multiple render windows. Basically, the example provided in the link creates an array of vtkRenderWindowInteractor objects, so that you can visualize multiple images.
2 - Using a single render window with viewports. The render window is splitted into viewports (renderer->SetViewport is the key, here), so that you can visualize n images at a time, where n is the number of viewports.
3 - Using the "slices" approach (the example works on DICOM files). This implements the "list" behaviour, as you said in your question. Basically, you visualize an image at a time, but you can navigate through them simply by pressing the arrow keys. The example derives the vtkInteractorStyleImage class to catch the events regarding key pressures.

Matlab: How to clear the previous output image

I define values for the variables and call the function, it returns the output image in the figure. But when i want to test another set of data, the output image will come out, it's together with the previous output image. How can i solve it, do i need to add what code at the end of the function file?
Either close all before your generate the new figure if you're not interested in the old output figure, or make a figure call before creating the new image to ensure it pops up in a new figure window. Or, you can overwrite the current open figure by setting hold off first, although that's specifically for graphs.

Plotting several jpeg images in a single display

I need to plot and display several jpeg images in a single combined display (or canvas?). For example, suppose I have images {a,b,c,d}.jpg, each of different size, and I would like to plot them on one page in a 2x2 grid. It would be also nice to be able to set a title for each subplot.
I've been thoroughly looking for a solution, but couldn't find out how to do it, so any ideas would really help. I would preferably use a solution that is based on the EBImage package.
There are two ways how to arrange several plots with base graph functions, namely par(mfrow=c(rows,columns)) (substitute rows and columns with integers) and layout(mat) where mat is a matrix like matrix(c(1,2,3,4)).
For further info see ?par, ?layout, and especially Quick-R: Combining Plots.
However, as your question is about images I don't know if it helps you at all. If not, I am sorry for misinterpreting your question.
To add to Henriks solution, a rather convenient way of using the par() function is:
jpeg(filename="somefile.jpg")
op <- par(mfrow=c(2,2)
#plot the plots you want
par(op)
dev.off()
This way, you put the parameters back to the old state after you ran the code. Be aware of the fact this is NOT true if one of the plots gave an error.
Be aware of the fact that R always put the plots in the same order. Using mfrow fills the grid row by row. If you use mfcol instead of mfrow in the code, you fill up column by column.
Layout is a whole different story. Here you can define in which order the plots have to be placed. So layout(matrix(1:4,nrow=2) does the same as par(mfcol=c(2,2)). But layout(matrix(c(1,4,3,2),ncol=2)) places the first plot lefttop, the next one rightbottom, the third one righttop, and the last one leftbottom.
Every plot is completely independent, so the titles you specify using the option main are printed as well. If you want to have more flexibility, you should take a look at lattice plots.
If you do not want the images in a regular grid (the different sizes could imply this), then you might consider using the subplot function from the TeachingDemos package. The last example in the help page shows using an image as a plotting character, just modify to use your different images and sizes/locations.
The ms.image function (same package) used with my.symbols is another possibility.

Resources