Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Plotting lookback time (in Gyrs) and redshift on two x axis in IDL
Hey, I recently came across this forum which discusses the difficulties in plotting two different x axis on the same plot. https://groups.google.com/forum/#!topic/comp.lang.idl-pvwave /_ooU4X875i0 One contributer wrote "IDL> plot,indgen(10),YRANGE=[1,12],YTITLE='first linear axis',YSTYLE=9,POSITION=[.1,.1,.9,.9],CHARSIZE=2 IDL> axis,YSTYLE=1,YAXIS=1,YTICKFORMAT='conv_axis',CHARSIZE=2,YTI TLE='second non-linear axis' where 'conv_axis' is the name of the function which does the conversion (e.g.): function conv_axis,axis,index,value return,string(FORMAT='(F0.1)',value^1.5*exp(-value^2/100)) end" I tried to use what this user wrote in my code: window,0 plot,res,rho*5000,/Ylog,XTITLE='Time (Gyr)',YTITLE='Log(dp/dt) (Solar Mass Mpc^-3 yr^-1)', XRange=[12,0] ;plot z against phi axis, XAXIS=1,XTICKFORMAT=z,XTITLE='redshift' Note: res is the time in gigayears given here: res=9.777505969(2./3/h/sqrt(1.omega_m))*asin(sqrt((1.omega_m )/omega_m)/(1.+z)^(3./2)) ;turns z into Giga years I was unsure what function to set equal to XTICKFORMAT, do i need to create a function to convert Gigayears into redshift? Please say if you would like to see any more of the code, as it is quite long i left most of it out. Thanks in advance, John
Re: Plotting lookback time (in Gyrs) and redshift on two x axis in IDL
I don't know... But I found it to be a lot more obvious what's going on if you just do what Fanning teaches us: http://www.idlcoyote.com/tips/another_yaxis.html http://www.idlcoyote.com/tips/irregular_tick_spacing.html note, for the second one, you can use the xtickv keyword and just set it equal to whatever array you want. Russell On Wednesday, December 3, 2014 6:47:19 AM UTC-5, johndra...@gmail.com wrote: > Hey, I recently came across this forum which discusses the difficulties in plotting two different x axis on the same plot. > > https://groups.google.com/forum/#!topic/comp.lang.idl-pvwave /_ooU4X875i0 > > One contributer wrote > > "IDL> plot,indgen(10),YRANGE=[1,12],YTITLE='first linear > axis',YSTYLE=9,POSITION=[.1,.1,.9,.9],CHARSIZE=2 > IDL> > axis,YSTYLE=1,YAXIS=1,YTICKFORMAT='conv_axis',CHARSIZE=2,YTI TLE='second > non-linear axis' > > where 'conv_axis' is the name of the function which does the > conversion (e.g.): > > function conv_axis,axis,index,value > return,string(FORMAT='(F0.1)',value^1.5*exp(-value^2/100)) > end" > > I tried to use what this user wrote in my code: > > window,0 > plot,res,rho*5000,/Ylog,XTITLE='Time (Gyr)',YTITLE='Log(dp/dt) (Solar Mass Mpc^-3 yr^-1)', XRange=[12,0] ;plot z against phi > axis, XAXIS=1,XTICKFORMAT=z,XTITLE='redshift' > > Note: res is the time in gigayears given here: > res=9.777505969(2./3/h/sqrt(1.omega_m))*asin(sqrt((1.omega_m )/omega_m)/(1.+z)^(3./2)) ;turns z into Giga years > > I was unsure what function to set equal to XTICKFORMAT, do i need to create a function to convert Gigayears into redshift? > > Please say if you would like to see any more of the code, as it is quite long i left most of it out. > > Thanks in advance, John
I understand that i can make one axis logarithmic in scale but i don't think this helps me as redshift isn't logarithmic with respect to lookback time (res). I have worked out what redshift is with respect to lookback time in Gyrs: z=(sqrt((1.-omega_m)/omega_m)/sin(res*3*h*sqrt((1.-omega_m)/ (2*9.777505969)))) Do you know if there is there anyway i can set the top axis to have this scaling within some set of values? please say if i haven't made it clear Thanks, John
On Wednesday, December 3, 2014 4:56:59 PM UTC-5, johndra...@gmail.com wrote> I understand that i can make one axis logarithmic in scale but i don't think this helps me as redshift isn't logarithmic with respect to lookback time (res). > > I have worked out what redshift is with respect to lookback time in Gyrs: > > z=(sqrt((1.-omega_m)/omega_m)/sin(res*3*h*sqrt((1.-omega_m)/ (2*9.777505969)))) > > Do you know if there is there anyway i can set the top axis to have this scaling within some set of values? > > please say if i haven't made it clear > > Thanks, John The functional form you choose is irrelevant. (1) Pick some redshifts for which you want the lookback time. (2) compute the lookback time. You keep giving that equation, and I think that's wrong. Where is Omega_lambda? where is time? Look at galage() in the astrolib. that is what you want. (3) now use the z values posited above with xtickv, xtickname, and axis to put the plot where you want. xr=[0,10] yr=[0,1] z=[1,2,3,4] ;redshifts to compute LB time for... ;Univ age at some redshift: t=galage(z,1000.,h0=69.6,omega=0.286,lambda=0.714,/sil)/1.0e 9 ;Univ age at today t0=galage(0.,1000.,h0=69.6,omega=0.286,lambda=0.714,/sil)/1. 0e9 ;LB time is difference... lb=t0-t ;draw the plot plot,[0],[0],xr=xr,xst=9,yr=yr,yst=1 ;set xst=9 to leave the top axis empty ;more plotting here ;draw the top axis axis,xaxis=1,xr=xr,xst=1,xtickv=z,xtickname=string(lb,f='(F4 .1)'),$ xticks=n_elements(z)-1