Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change aspect ratio of inset axes from `zoomed_inset_axes`

Tags:

matplotlib

How do i change the dimensions of an inset axes object?

I'm creating a plot like this:

enter image description here

I would like the inset to be wider, the zoomed_inset_axes method defaults to the same aspect ratio as the underlying data (sensibly i guess), but it seems to resist any attempt I make to change it...

I'm using it like this:

axins.axis(args.inset_extent)
os = axins.get_position()
pos = [pos.x0, pos.y0,  pos.width * 2, pos.height]
axins.set_position(pos)

I've tried the which kwarg of set_position too, and that also appears to do nothing.

How can i set the position of the inset plot, and more importantly change it's aspect ratio?

It's part of a reasonably long plotting script, the full code is here, and a couple of example basis sets to try it are here: 6-31G.dat and 3-21G.dat.

Just download them into their own dir, and put the basis set files in a dir called basis_sets, and then use the command:

./basis_sets.py -r -2 2 -b 6-31G 3-21G -a C --inset --inset-zoom 6 --inset-extent -0.03 0.03 6.7 7.7

(./basis_sets.py --help prints out usage guide)

like image 548
will Avatar asked Oct 15 '25 09:10

will


1 Answers

So i found another function in there, just called inset_axes.

It's used a little differently, but does exactly what i want, and the mark_inset helper function still works too, which is nice.

So now i have:

ax = inset_axes(ax, width=XX, height=XX, loc=XX)
ax.axis([x0, x1, y0, y1])

istead of the zoom one and it is much more flexible.

like image 75
will Avatar answered Oct 17 '25 13:10

will