Code covered by the BSD License  

Highlights from
figure inset

4.41667
4.4 | 12 ratings Rate this file 66 Downloads (last 30 days) File Size: 1.87 KB File ID: #28549
image thumbnail

figure inset

by

Moshe Lindner (view profile)

 

25 Aug 2010 (Updated )

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 file inspired The Krouchev Journal Figure Advanced Matlab Toolkit and Mag Inset.

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (21)
27 Aug 2014 Degang

Degang (view profile)

While this short piece of code does create an inset for simple plots, it will break for slightly more sophisticated plots, e.g., plots with legends. Besides, the position of the inset is hard-coded.

20 May 2013 Carlos

Carlos (view profile)

I mistakenly added the comment as a tag. Deletion doesn't seem to be working for me. My apologies.

05 Apr 2013 Aous

Aous (view profile)

Thanks for a useful code.
Can one use this code to draw an insert inside a subplot? I tried doing so by commenting the line in the code that creates new figure but that didn't work.

Comment only
05 Apr 2013 Aous

Aous (view profile)

Thanks for a useful code.
Can one use this code to draw an insert inside a subplot? I tried doing so by commenting the line in the code that creates new figure but that didn't work.

20 Jan 2013 Moshe Lindner

Moshe Lindner (view profile)

Hi Suasn.
In ordet to do so, you should remove the command that open a new figure from the code (line 16).

Moshe.

Comment only
17 Jan 2013 Susan

Susan (view profile)

Hi Moshe,

Thanks for this useful code. I'm having a bit of bother trying to do something. I plot figure(1); I wish to inset a magnified portion of figure(1) (i.e. figure(2)) into figure(1) itself. Is this possible with your code?

17 Jan 2013 Susan

Susan (view profile)

Hi Moshe,

Thanks for this useful code. I'm having a bit of bother trying to do something. I plot figure(1); I wish to inset a magnified portion of figure(1) (i.e. figure(2)) into figure(1) itself. Is this possible with your code?

Comment only
28 Dec 2012 Benjamin Pavie  
27 Aug 2012 Doug

Doug (view profile)

v. nice, useful tool.

03 Jul 2012 Nolan C  
25 Jun 2012 Sam_K

Sam_K (view profile)

 
04 Jun 2012 Nikolaos Anesiadis

Great code. Simple and works absolutely fine.

11 Mar 2012 Moshe Lindner

Moshe Lindner (view profile)

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])

Comment only
07 Mar 2012 dd

dd (view profile)

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

Comment only
18 Dec 2011 Moshe Lindner

Moshe Lindner (view profile)

Eric - thanks for your comment.

Comment only
16 Dec 2011 Erik

Erik (view profile)

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!

Comment only
24 Nov 2011 Shatrughan

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

24 Aug 2011 Moshe Lindner

Moshe Lindner (view profile)

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])

Comment only
22 Aug 2011 Aditi Goswami

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

Comment only
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.

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!

Updates
26 Aug 2010

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

Contact us