Setting position of smaller plot within a larger plot to be a data point of the first larger plot

4 views (last 30 days)
Hi All.. this is an interesting question if anyone has tried it. I wish to have a plot within a plot but the small insert plots are to be positioned on some data points of the larger plot.
So for example if the large plot has an axis range -4<x<4 -4<y<4
The smaller inset plot's origin is to be positioned at point (-1,2) on the larger plot
The smaller inset plot is to also have an axis width and height that is equal to to 0.5 unit in length and 0.5 unit in height on the larger plot (note this is the width of the axis in the plot not the range of the axis, the range of the smaller axes for the inset plot can be any arbitrary number, but it's physical size is to be 0.5 high and wide on the grid of larger plot)
How do you do this? Defining an axes position is determined from the the window size of a figure and not from the axes origin of the larger plot.
Here is an example here, but it shows the inset plot using the figure's dimensions

Answers (1)

Adam
Adam on 21 Apr 2015
Edited: Adam on 21 Apr 2015
The axes has a position too, relative to the figure, so you can just map your location in axes coordinates onto an e.g. pixel coordinate relative to the axes origin (position) and then add this to that axes origin to get the location relative to the figure.
You may have to convert units a few times, e.g. from 'normalized' to 'pixels' for the figure and axes to work out the position and then convert everything back to normalized to get the size right and ensure resizing behaviour.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!