Missing something with parasite axes (AxesGrid toolkit)

Hi guys,

I am trying to use the Axes grid toolkit to plot a graph with a second y axes that gives the first y axes in different units (similar to http://matplotlib.sourceforge.net/examples/axes_grid/parasite_simple2.html?highlight=subplothost). I am clearly getting something wrong or missing something as I get both y axes but no graph inbetween. Plot and script attached. Please can anyone see what I have got wrong or point me in the direction of more extensive documentation about parasite axes or SubplotHost?

Many thanks,

Libby

StellarMass.py (4.2 KB)

StarMassExp_GMCirbrp128_GMCirbrp128.eps (25.5 KB)

···


Elizabeth Harper-Clark MA MSci
PhD Candidate, Canadian Institute for Theoretical Astrophysics, UofT
Sciences and Engineering Coordinator, Teaching Assistants’ Training Program, UofT

www.astro.utoronto.ca/~h-clark
h-clark@…3512…
Astronomy office phone: +1-416-978-5759

Hi guys,

I am trying to use the Axes grid toolkit to plot a graph with a second y axes that gives the first y axes in different units (similar to http://matplotlib.sourceforge.net/examples/axes_grid/parasite_simple2.html?highlight=subplothost). I am clearly getting something wrong or missing something as I get both y axes but no graph inbetween. Plot and script attached. Please can anyone see what I have got wrong or point me in the direction of more extensive documentation about parasite axes or SubplotHost?

Many thanks,

Libby

StellarMass.py (4.2 KB)

StarMassExp_GMCirbrp128_GMCirbrp128.eps (25.5 KB)

···


Elizabeth Harper-Clark MA MSci
PhD Candidate, Astrophysics, UofT

www.astro.utoronto.ca/~h-clark

h-clark@…3512…
AIM: edphc1
MSN: edphc1@…32…
Skype: eharperclark
Office phone: 416-978-5759

Hello,

I’ve been playing with the script and I now know a little bit more about what is wrong. I can get the full graph space to plot by changing:

ax_mass = SubplotHost(fig, 1,1,1, aspect=1.)
to
ax_mass = SubplotHost(fig, 1,1,1)

but then a line is never drawn. I have removed the x and y axis limits and it plots the axes for the limits of the date but no line for the graph? Here is the relevant part of the code:

fig = plt.figure()
ax_mass = SubplotHost(fig, 1,1,1)

frac_to_mass = gasmass
print ‘frac_to_mass’, frac_to_mass
aux_trans = mtransforms.Affine2D().scale(1., frac_to_mass)
ax_frac = ax_mass.twin(aux_trans)
ax_frac.set_viewlim_mode(“transform”)

fig.add_subplot(ax_mass)
ax_mass.plot(time,massesMsun, linestyle=‘-’, color=‘k’, linewidth=2.0)

ax_mass.axis[“bottom”].set_label(“Time (Myrs)” )
ax_frac.axis[“right”].set_label(“Fraction of Original Gas Mass in Stars” )
ax_mass.axis[“left”].set_label(“Mass in Stars (Msun)” )
ax_frac.axis[“right”].major_ticklabels.set_visible(True)
ax_frac.axis[“top”].major_ticklabels.set_visible(False)
plt.savefig(frame_template %(folder,name[0],name[int(sys.argv[1])-1]), format=“eps”)

can I not use ax_mass.plot?

Thanks,

Libby

···

On 4 April 2011 17:00, Elizabeth Harper-Clark <h-clark@…3512…> wrote:

Hi guys,

I am trying to use the Axes grid toolkit to plot a graph with a second y axes that gives the first y axes in different units (similar to http://matplotlib.sourceforge.net/examples/axes_grid/parasite_simple2.html?highlight=subplothost). I am clearly getting something wrong or missing something as I get both y axes but no graph inbetween. Plot and script attached. Please can anyone see what I have got wrong or point me in the direction of more extensive documentation about parasite axes or SubplotHost?

Many thanks,

Libby


Elizabeth Harper-Clark MA MSci

PhD Candidate, Astrophysics, UofT

www.astro.utoronto.ca/~h-clark

h-clark@…3512…

AIM: edphc1
MSN: edphc1@…32…
Skype: eharperclark
Office phone: 416-978-5759


Elizabeth Harper-Clark MA MSci
PhD Candidate, Astrophysics, UofT

www.astro.utoronto.ca/~h-clark

h-clark@…3512…
AIM: edphc1
MSN: edphc1@…32…
Skype: eharperclark
Office phone: 416-978-5759

Sorry for another email,

Please all ignore my previous emails, I have figured it out and it was a stupid error on my part plotting time rather than time[0] etc.

Apologies and best wishes,

Libby

···

On 4 April 2011 17:50, Elizabeth Harper-Clark <h-clark@…120…3512…> wrote:

Hello,

I’ve been playing with the script and I now know a little bit more about what is wrong. I can get the full graph space to plot by changing:

ax_mass = SubplotHost(fig, 1,1,1, aspect=1.)
to
ax_mass = SubplotHost(fig, 1,1,1)

but then a line is never drawn. I have removed the x and y axis limits and it plots the axes for the limits of the date but no line for the graph? Here is the relevant part of the code:

fig = plt.figure()
ax_mass = SubplotHost(fig, 1,1,1)

frac_to_mass = gasmass
print ‘frac_to_mass’, frac_to_mass
aux_trans = mtransforms.Affine2D().scale(1., frac_to_mass)
ax_frac = ax_mass.twin(aux_trans)
ax_frac.set_viewlim_mode(“transform”)

fig.add_subplot(ax_mass)
ax_mass.plot(time,massesMsun, linestyle=‘-’, color=‘k’, linewidth=2.0)

ax_mass.axis[“bottom”].set_label(“Time (Myrs)” )
ax_frac.axis[“right”].set_label(“Fraction of Original Gas Mass in Stars” )

ax_mass.axis[“left”].set_label(“Mass in Stars (Msun)” )
ax_frac.axis[“right”].major_ticklabels.set_visible(True)
ax_frac.axis[“top”].major_ticklabels.set_visible(False)
plt.savefig(frame_template %(folder,name[0],name[int(sys.argv[1])-1]), format=“eps”)

can I not use ax_mass.plot?

Thanks,

Libby

On 4 April 2011 17:00, Elizabeth Harper-Clark <h-clark@…3512…> wrote:

Hi guys,

I am trying to use the Axes grid toolkit to plot a graph with a second y axes that gives the first y axes in different units (similar to http://matplotlib.sourceforge.net/examples/axes_grid/parasite_simple2.html?highlight=subplothost). I am clearly getting something wrong or missing something as I get both y axes but no graph inbetween. Plot and script attached. Please can anyone see what I have got wrong or point me in the direction of more extensive documentation about parasite axes or SubplotHost?

Many thanks,

Libby


Elizabeth Harper-Clark MA MSci

PhD Candidate, Astrophysics, UofT

www.astro.utoronto.ca/~h-clark

h-clark@…3512…

AIM: edphc1
MSN: edphc1@…32…
Skype: eharperclark
Office phone: 416-978-5759


Elizabeth Harper-Clark MA MSci
PhD Candidate, Astrophysics, UofT

www.astro.utoronto.ca/~h-clark

h-clark@…3512…
AIM: edphc1
MSN: edphc1@…32…
Skype: eharperclark
Office phone: 416-978-5759


Elizabeth Harper-Clark MA MSci
PhD Candidate, Astrophysics, UofT

www.astro.utoronto.ca/~h-clark

h-clark@…3512…
AIM: edphc1
MSN: edphc1@…32…
Skype: eharperclark
Office phone: 416-978-5759