Code covered by the BSD License  

Highlights from
figure inset

4.33333

4.3 | 3 ratings Rate this file 94 Downloads (last 30 days) File Size: 1.87 KB File ID: #28549
image thumbnail

figure inset

by Moshe Lindner

 

25 Aug 2010 (Updated 26 Aug 2010)

The function plotting figure inside figure (main and inset) from 2 existing figures.

| Watch this File

File Information
Description

The function plotting figure inside figure (main and inset) from 2 existing figures.

Acknowledgements
This submission has inspired the following:
The Krouchev Journal-Figure Advanced MATLAB Toolkit
MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (9)
10 Sep 2010 Ernesto Momox Beristain

Simple code that does the job. However, it would be nice to place the inset in a similar way as with the legends, i.e.,

legend('My_inset','Location','SouthEast');

It works though!

05 Mar 2011 Marco Buiatti

I confirm the previous comment: simple to use, it does the job, the example is nicely illustrative.
Only bug: when I inserted it into a matlab function plotting several consecutive plots (main + inset), it did not work until I numbered figures with high numbers. I guess there's a trivial interference between the number of the composite figure (automatically the lowest available) and the number of the following figures.

22 Aug 2011 Aditi Goswami

How do I change the position of the inset on the main plot, to say 'SouthEast'?

24 Aug 2011 Moshe Lindner

Hi Aditi.
You need no modify the last line in the function.
try to cahnge it to:
set(h_inset,'Position', [.7*ax(1)+ax(3)-inset_size 1.4*ax(2) inset_size inset_size])

24 Nov 2011 Shatrughan

extremely useful and great !!! easy to work with...Keep rocking .........

16 Dec 2011 Erik

When using legends, the code does not work if a legend is added in fig1 or fig2 (referring to the notation in the inset_example.m file) before calling the inset function. Adding a legend to fig1 seems to give it two different axes, which confuses inset.m.

A legend can however, be added afterwards to the new figure containing the inset by adding the row legend(h_m,'toggle') or legend(h_i,'toggle') at the bottom of inset_example.m.

Thanks for a nice code!

18 Dec 2011 Moshe Lindner

Eric - thanks for your comment.

07 Mar 2012 dd

Hi,
How do you get it then at N-W position?
Thks

11 Mar 2012 Moshe Lindner

Hi dd.
try to change the last line in the code to:
 set(h_inset,'Position', [.7*ax(1)+0.2*(ax(3)-inset_size) .5*ax(2)+ax(4)-inset_size inset_size inset_size])

Please login to add a comment or rating.
Updates
26 Aug 2010

in the new version, the user can determine the size of the inset-figure

Tag Activity for this File
Tag Applied By Date/Time
inset Moshe Lindner 25 Aug 2010 10:58:34
insert Moshe Lindner 25 Aug 2010 10:58:34
figure Moshe Lindner 25 Aug 2010 10:58:34
graphics Moshe Lindner 25 Aug 2010 10:58:34
plot Moshe Lindner 25 Aug 2010 10:58:34
figure Jorge Neves 15 Sep 2011 11:35:46
inset Anirban 26 Oct 2011 11:41:23

Contact us at files@mathworks.com