Some tips on plotting December 22, 2008

Posted by keithkchan in Trivia.

Recently I tried to make a plot of mass function of halos, and I found that it was a little bit tricky, so I would ike to make a post here, and hopefully it would be useful to some of the readers of the Blackboard.

First suppose you want to plot, say, $E=\hbar \omega$. Well, it is a straight line. In the plot, you can select log scales for x and y axes, so you get a log-log plot. Another example is the blackbody radiation energy density per unit frequency $I(\nu)$ as a function of frequency $\nu$.   Now you want to plot the energy density as a function of wavelength $\lambda$. You may remember that in addition to $f(\lambda)$, there is a factor of $c/ \lambda^2$ from the Jacobian. This is because after integrating the energy density per unit wavelength over all the wavelength, we should get the energy density.

With these examples in mind, I would like to talk about the mass function of halo $dn/dM$, the number of halos per unit mass per unit volume. In the literature, people always plot in log-log plot for the mass function. You divide the mass in the uniform interval, and count the number of halos in each mass interval, and then divide by the volume and mass interval. At the end of the day, you can re-scale the axes from linear to log scale. Heck, it is wrong! This is different from the example $E=\hbar \omega$, as E only depends on the value of $\omega$, but not its width. This case is similar to blackboard radiation since you change the axis from M to logM, you’d better not to forget the Jacobian M. So you should plot $M\frac{dn}{dM}$ when you use the log scale.

However, in the case of mass function, it becomes very noisy in the high mass regime if you use uniform interval in M. A better strategy is to use interval uniform in logM, and divide the number of halos in each bin by logM interval, then you will get the mass function in log scale directly as I did.