Monthly Archives: April 2012


I like to think that, 18 months (and three papers) into my PhD, I’ve learned a lot about how science works. The naive beliefs of my undergrad days have all but vanished, replaced with (presumably) slightly less naive ones. Science is messier than I thought, less “clean”. Things go wrong, mistakes are made, guesswork reigns, and absolute rigour is never attained. People, personalities and politics play a big role; egos and reputations are involved, and disagreements are common. Motivations are varied; not everyone is committed to some uniform ideal of “discovery” or “openness”. Science is a career like any other; success is not guaranteed, hard choices and sacrifices must be made, and some form of work/life balance attained. (By now, you might be thinking that I’ve been reading a little too much of PhD Comics, or that my supervisor has had the “getting a job” talk with me. Correcto.)

But while it’s easy to find expositions on the hidden flaws of academia all over the web, there have been plenty of pleasant aspects that I wasn’t expecting either. One thing that I’ve been getting a kick out of recently is exposure, or “recognition”, of my work. Although still decidedly a newcomer to the rarefied cosmological subfields in which I work, I’ve now put out enough papers and shown my face at enough conferences that some people know who I am and what I’ve been doing. So, when a scrap of evidence that someone cares about my work appears, it’s a great feeling. The novelty will wear off, I’m sure, and it’s hardly the reason I get up in the morning, but it is nice.

Some of the exposure that I’m talking about could be reasonably well expected, since my seniors in the department talk about it often enough. Citations? Check. Emails from other researchers? Yep. Cranks emailing me? Of course. But a couple of recent events were particularly pleasant, and wholly unexpected.

The first was having our kSZ+voids paper mentioned in Ellis, Maartens and MacCallum’s new textbook on relativistic cosmology (which looks excellent, by the way). Although I don’t believe that textbooks have any special claim to authority over other media, the fact that the paper is mentioned in one amplifies the feeling of having contributed something to the state of human knowledge, however minor. Maybe it’s my perception of books as being relatively permanent entities that does it? I should carve the damn thing in stone if that’s the case.

The second was being approached by a journalist and interviewed, by email, about some of my research. Some of this appears in a story about alternatives to dark energy on the PBS NOVA physics blog. That was an interesting experience too, and I like the idea that members of the general public will gain some insight into what I’m working on. Of course, I was exposed to some of the harsh realities of science/media interaction in the process – the story paints a very simplified picture of a complicated area of study, fails to credit lots of people who made important contributions, etc. (although for what it’s worth, I think the author, Charles, did a pretty good job). But it was still a good feeling to see my stuff mentioned in print (as it were).

I don’t anticipate changing my stance of “doing science because it’s interesting” and becoming a publicity whore off the back of these, but they put a smile on my face nevertheless.


Drawing arrows in Matplotlib

This is a fun one. A colleague of mine spent a while this afternoon trying to get arrows to work in Matplotlib, so that he could draw upper-limit points on a graph (similar to this). All to no avail – the arrow() function would happily draw lines, but without an arrow head. He came to ask about it, and we spent a little while digging into the documentation to see what was up.

As it turns out, the documentation was what’s up. The function reference for arrow() is missing information about some rather important keyword arguments, the ones that control arrow head presentation. Even worse, in the versions of Matplotlib we’re using, the default option seems to be to display no arrow head at all! This is clearly broken – arrows should look like arrows by default.

Fortunately, there were a couple of code examples available on the Matplotlib website. Unfortunately, one was rather complicated (312 lines of code!), and the other wasn’t really what he was looking for (fancy arrows in LaTeX). We ended up trying to reverse-engineer the first example, which is when we stumbled upon the extra, undocumented, keyword arguments that would make everything work in a nice, easy way. These are head_length and head_width, which need to be set to non-zero float values to display an arrow head.

I’ve included a minimal example below – it just draws a black arrow with a sensibly-proportioned arrow head.¬†There are other arrow style keywords that you can use too; look at the ArrowStyle documentation to see them listed.

import pylab as P
# P.arrow( x, y, dx, dy, **kwargs )
P.arrow( 0.5, 0.8, 0.0, -0.2, fc="k", ec="k",
head_width=0.05, head_length=0.1 )

Drawing an arrow in Matplotlib