Monday, July 16, 2012

Making Awesome Latex Tables

Yep, still disserating... thus all the posts are more about the process of writing than actual science research.  Here is a post about how to make awesome looking tables using latex and deluxetable.

I like using the deluxetable style in latex because the tables look nicer than normal latex tables, and you have more flexibility.  Below is an example of a cool table with come nice features that I made for my thesis:



Latex Code:

\begin{deluxetable}{cccccccc}
\tabletypesize{\footnotesize}
\tablecolumns{8} 
\tablewidth{0pt}
\tablecaption{ Cross-correlation Fit Details
\label{tab:lumresults1}}
\tablehead{
\colhead{QSO} \vspace{-0.2cm}& \colhead{$R$ Range} &  & & &  &\colhead{Separation} & \colhead{Result}\\ \vspace{-0.2cm}
& & \colhead{$\langle f \rangle$} & \colhead{$r_0$} &  \colhead{$\gamma$}& $W$ & & \\
\colhead{Division} & \colhead{(Mpc/h)} & \colhead{} & \colhead{} & \colhead{}&& \colhead{(\%)} & \colhead{Strength}} 
\startdata 
\vspace{-0.2cm} \nicefrac{1}{3} Bright &  & $4.24 \cdot 10^{-4}$ & 6.19 && 96.97 & &\\ \vspace{-0.2cm}
& [0.3,3] & & & 1.77 & &  96.7 & 1.9$\sigma$ \\ 
 \nicefrac{2}{3} Dim & & $4.26 \cdot 10^{-4}$ & 4.48 & & 52.77
\enddata
\vspace{-0.8cm}
\tablecomments{Luminosity dependent quasar clustering using a cross-correlation technique between CS82 galaxies ($M < 23.5$) and SDSS, BOSS, and 2SLAQ quasars \hbox{($0.5$)}}
\end{deluxetable}


Note that you need the file deluxetable.sty from here.

Sunday, July 8, 2012

Fun with Python Axes

Sometimes you want to make a plot with two axes, and sometimes you also want the tickmarks on both those axes to look a certain way.  Here's how you do it:




fig = plt.figure(figsize = (11,10))
ax = fig.add_subplot(111)
for i in range(size(magcuts)): ax.plot(xdata[i],ydata[i], label=label[i], linewidth = 2.0)

leg = ax.legend(loc=3,shadow=False,prop=FontProperties(size=25),fancybox = True)
leg.get_frame().set_alpha(0
ax.set_xlabel("$\\chi \\mathrm{\\ (Mpc/h)}$",fontsize=30)
ax.set_ylabel("$f(\\chi)$",fontsize=30)

bx = twiny()
bx.plot(xdata2,ydata,alpha=0)
bx.set_xlabel("$\\mathrm{redshift\\ }(z)$",fontsize=30)

ticklabels = bx.get_xticklabels()
for label in ticklabels:
    label.set_fontsize(18)
    label.set_family('serif')   

ticklabels = ax.get_xticklabels()
for label in ticklabels:
    label.set_fontsize(18)
    label.set_family('serif')            

ticklabels = ax.get_yticklabels()
for label in ticklabels:
    label.set_fontsize(18)
    label.set_family('serif'
    
    
filename = "plot2save"
savefig(filename + '.eps',format = 'eps', transparent=True)
savefig(filename + '.pdf',format = 'pdf', transparent=True)
savefig(filename + '.png',format = 'png', transparent=True)