Hi everyone,

I'm trying to make a zoom of a single plot. The problem is that the zoomed
axes yticks overlap with the yaxes so I tried to use the bbox_to_anchor
option in the zoom:
axins = zoomed_inset_axes(ax,
3,bbox_to_anchor=(0.4,0.4),bbox_transform=ax.transAxes, loc=2)

with different (x,y) parameters, but it's not working.

I also tried to move the figure by hand:
box = axins.get_position()
print box
axins.set_position([box.x0+0.5, box.y0,box.width, box.height])
box = axins.get_position()
print box

and I see that box numbers changing, but not in the plot.

Can anyone guess what I am doing wrong?

Thank you all!

PS: The full code for this plot is:

def plotvsdata(data,z,dl,nu):
    """
    Plot of z vs. Dl for different nu values
    """

    fig = p.figure(figsize=(12,8))
    ax = p.subplot(111)

    # FLRW light distance
    ax.plot(z[0],Dl_lflrw(z[0],0.3,0.7),'k--',label=r'Dl $\Lambda$FLRW')
    # mean data values
    ax.plot(data.redshift,data.distance,'r.',label='SCP data')

    p.xlabel('z',fontsize=18)
    p.ylabel('Luminosity distance',fontsize=18)
    p.grid(True)

    #axins = zoomed_inset_axes(ax,3,loc=2,bbox_to_anchor=(0.5,0.5))
    #axins = zoomed_inset_axes(ax,3,loc=2,bbox_to_anchor=(0.4,0.4)
,bbox_transform=ax.transAxes)
    axins = zoomed_inset_axes(ax,
3,bbox_to_anchor=(1,1),bbox_transform=ax.transAxes, loc=2)
    #box = axins.get_position()
    #print box
    #axins.set_position([box.x0+0.5, box.y0,box.width, box.height])
    #box = axins.get_position()
    #print box


    # Kantowski equation
    for i in range(len(z)):
        ax.plot(z[i],dl[i],label=r'$\nu={0:1.2f}$'.format(nu[i]))
        axins.plot(z[i],dl[i])
    axins.plot(data.redshift,data.distance,'r.', label='SCP data')


    #box = ax.get_position()
    #ax.set_position([box.x0,box.y0,box.width*0.8,box.height])

    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))
    #box = axins.get_position()
    #print box
    #axins.set_position([box.x0+0.5, box.y0,box.width, box.height])
    #box = axins.get_position()
    #print box

    # draw a bbox of the region to zoom and connecting lines between it
    # and the zoomed box.
    mark_inset(ax,axins,loc1=1,loc2=3, fc="none", ec="0.5")
    #p.xticks(visible=False)
    #p.yticks(visible=False)

    p.draw()
    p.show()
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to