|
From: darkside <in....@gm...> - 2012-09-12 09:16:28
|
Thank you for your help.
A simple example that doesn't work for me is:
----------------------------------------
import pylab as p
import numpy as np
from mpl_toolkits.axes_grid.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid.inset_locator import mark_inset
from mpl_toolkits.axes_grid.anchored_artists import AnchoredSizeBar
from matplotlib.ticker import MaxNLocator
fig = p.figure(figsize=(12,8))
ax = p.subplot(111)
z = p.arange(0,1.415,0.01)
d = z**2+np.random.random(len(z))
ax.plot(z,d,'ro',label='text')
p.xlabel('z',fontsize=18)
p.ylabel('Luminosity distance',fontsize=18)
p.grid(True)
axins = zoomed_inset_axes(ax,
3,bbox_to_anchor=(0.5,0.5),bbox_transform=ax.figure.transFigure, loc=2)
axins.plot(z,d,'r.')
ax.legend(loc=2,bbox_to_anchor=(1,1))
x,y = (0.86,1.3)
x2,y2 = (1,1.7)
axins.set_xlim(x,x2)
axins.set_ylim(y,y2)
axins.tick_params(axis='both',labelsize=12)
axins.xaxis.set_major_locator(MaxNLocator(2))
axins.yaxis.set_major_locator(MaxNLocator(3))
mark_inset(ax,axins,loc1=1,loc2=3, fc="none", ec="0.5")
p.draw()
p.show()
-----------------------------------------------------------
The "bbox_to_anchor" label is supposed to move the zoomed axis, but it does
nothing, no matter what two numbers I place there.
I guess that I miss something, but I can't figure out what. I really
appreciate your help.
Best regards,
Illa
2012/9/5 Jae-Joon Lee <lee...@gm...>
> On Mon, Aug 20, 2012 at 10:50 PM, darkside <in....@gm...>
> wrote:
> > I am using zoomed_inset_axes, but the default position overlaps the
> yticks
> > and the parent axe ticks, so I am trying:
> > axins = zoomed_inset_axes(ax,
> > 3,bbox_to_anchor(0.5,1),bbox_transform=ax.figure.transFigure, loc=2)
>
> This is supposed to work, and my quick test did work. Can you post a
> complete but simple exampl?
>
> Regards,
>
> -JJ
>
|