Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot Overlay MATLAB

How do you take one plot and place it in the corner (or anywhere for that matter) of another plot in MATLAB?

I have logarithmic data that has a large white space in the upper right-hand side of the plot. In the white space I would like to overlay a smaller plot containing a zoomed in version of the log plot in that white space (sort of like a magnified view).

Before you tell me it can't be done, I would like to mention that I have seen it in action. If my description is lacking, just let me know and I'll attempt to better describe it to you.

like image 786
ServAce85 Avatar asked Nov 16 '09 20:11

ServAce85


People also ask

How do you overlay a plot?

Creating an Overlay Plot Then to add an overlay plot to the project, choose Home > Insert > Overlay Plot. In the window that appears, select the data sheets/diagrams you want to include in the plot (up to a maximum of 20) and click OK to create the plot sheet.

How do I overlay one image over another in Matlab?

Create Blended Overlay of Two ImagesCreate a copy with a rotation offset applied. A = imread('cameraman. tif'); B = imrotate(A,5,'bicubic','crop'); Create blended overlay image, scaling the intensities of A and B jointly as a single data set.


2 Answers

An example:

x = 1:20;
y = randn(size(x));

plot(x, y,'LineWidth',2)
xlabel('x'), ylabel('y'), title('Plot Title')

h = axes('Position', [.15 .65 .2 .2], 'Layer','top');
bar(x,y), title('Bar Title')
axis(h, 'off', 'tight')

screenshot

like image 69
Amro Avatar answered Sep 25 '22 00:09

Amro


You can use axes properties 'position' and 'units' and make them overly. Pay attention to create small axes after big one or use uistack() function so that big does not hide small one.

What you can not do is to make an axes child of another one (like Mathworks do with legend). But you do not need it anyway.

For the second plot you have to use axes and line instead of plot and hold on.

Units as 'normalized' (which is default) allows uniform resizable look when parent figure is being resized (e.g. manually maximized).

like image 45
Mikhail Poda Avatar answered Sep 27 '22 00:09

Mikhail Poda