I'm doing an astrophysics thesis with a lot of programming in Python. I'm currently using gnuplot for my plots, but I wonder if this is actually looking quite professional. Are there other options which look better and are still easy to use?

Here an example of a figure in my thesis:

Example Figure

The vertical line I got with the following command:

set arrow from 4861.3,-1200 to 4861.3,2000 nohead lc 2  

I know it reaches out of the figure, but I use this command for all of my script and I know only at the end what the upper and lower boundary of the y-axis will be. Every peak is different.

  • 8
    I do not think there is anything wrong with GNUPlot, it is probably more important how you design the plots within GNUPlot, see for example academia.stackexchange.com/q/10282/4394 May 30, 2013 at 13:01
  • 3
    Gnuplot is the choice of plotting tool. Go ahead, be good at it and there will be little chance you go wrong. There are plenty of resources in the internet (e.g. Gnuplotting), and also Janert's book, Gnuplot in action. Good luck!
    – user7116
    May 30, 2013 at 13:11
  • 1
    Do you have an example of a typical plot in your thesis? If you do, then you can probably post it and ask, "What can I do to improve this plot?" and solicit specific advice rather than just asking about alternative software packages that may or may not help you.
    – Irwin
    May 30, 2013 at 16:08
  • @Irwin: editted the question. May 31, 2013 at 7:25
  • 1
    If you know where the peak is, how come you don't know how high it is? Why use an arrow without a head instead of plotting a new line of data with two points? There are problems with the graph--legends should be larger than tick labels, line width could maybe be a bit thicker, having stuff like u($1/(1.9072)):2 (or even the file name) is not very professional-looking. But these are all fixable with a bit of effort without using something other than Gnuplot.
    – Rex Kerr
    May 31, 2013 at 17:02

4 Answers 4


If you do the programming in Python, you could also do the plotting in Python with matplotlib. With a little adjustment of the plotting parameters, it is possible to produce publication-quality plots with this software.

Alternatively, if you need fancy annotations etc., I can recommend the pgfplots package for tikz/LaTeX. You could export data from your Python program to a csv file, and then use that as data source for plotting with pgfplots. If you are also using TeX for the main text, it allows to to produce graphics which nicely fit the formating of the text.

  • 2
    With matplotlib you can also generate figures with LaTeX text and formulas in them
    – Zenon
    Jun 1, 2013 at 10:17

It is difficult to produce professional-looking output from Gnuplot (even harder than it is from Matlab, which I also wouldn't recommend).

Since you're already using Python, matplotlib is the obvious choice. You you can even make a decent attempt at producing full figures, not just one panel.

Typically astrophysics doesn't have much reference to astronomy these days. However, if your thesis does, you might also want to check out APLpy which adds on to matplotlib.

  • 5
    you say: "It is difficult to produce professional-looking output from Gnuplot". I beg to disagree, Gnuplot is excellent if you use it with care, at least for two-dimensional plots.
    – user7116
    May 30, 2013 at 20:07
  • 1
    @MarcusAntoninus - What is the difference between "difficult" and "with care"?
    – Rex Kerr
    May 30, 2013 at 20:12
  • 1
    @MarcusAntoninus - Just for reference, I view the graphs in phyast.pitt.edu/~zov1 as borderline in terms of publication-quality.
    – Rex Kerr
    May 30, 2013 at 20:15
  • 2
    @RexKerr could you go into more depth as to what is wrong with the plots in the link you gave, they look basic, but essentially functional. I've seen worse in publications. May 31, 2013 at 12:59
  • 1
    @PaulHiemstra - All of them are badly aliased. In the first one, the axis labels are too small--all the text is, really--and the erf label is too close to the border. In the second one, the tick labels are not helping anything and the arrow looks cartoonish. The third one is good; only the tick labels are too long. The fourth is just ugly; you need less space and wavy lines not just slashes to indicate space, and you need it on the graph line as well. The fifth has bad axis label spacing (including tick labels), and the smoothing has introduced a shift in the data. You get the idea.
    – Rex Kerr
    May 31, 2013 at 16:46

For the plot you've shown, I have a couple of suggestions to make it look more "professional". (Maybe you're already doing some of these in the actual document.)

  • Use a vector-based file format; your lines will look smoother, up to the resolution of your printer. I suggest set terminal pdf.

  • Set a meaningful title for the curve: plot "tkrs.txt" using ... title "Dilithium flux density". Or omit it completely: plot "tkrs.txt" using ... notitle.

  • If plotting a mathematical function (rather than a dataset), set samples 5000 or something similarly high for your final output.

  • Try to choose a font for the labels that matches the paper's text as closely as possible. See help term pdf for more info, and other interesting tweaks. You can also use non-ASCII characters (e.g. Å instead of angstrom).

  • Set the plot to a size and aspect ratio that fits nicely on the page, preferably so that your word processor (or LaTeX) doesn't have to rescale it.

  • For your vertical line, you could cheat and use a parametric function, so that it will be clipped to the boundaries of the plot. It's a little tricky because if you make the line extra long, by default the plot will be rescaled to fit all of it. But there is a way to avoid this:

    set xrange [ ] writeback
    set yrange [ ] writeback
    plot "tkrs.txt" ...
    set parametric
    set trange [-1200:10000]
    set xrange restore
    set yrange restore
    replot t, 4861.3 notitle

  • Thx a lot for the hints, I'll try them all next week. May 31, 2013 at 14:14

The choice of plotting choice will depend on several factors. First, it is important to state that there are many options, from GNUPlot, through commercial plotting packages such as Grapher and Origin, plotting capabilities of Matlab and R to plotting using specific packages such as pgfplots (LaTeX) or graphics packages accompanying programming languages (e.g. PSPlot). What you chose will depend on other factors such as what your peers use, what you may have become familiar with and perhaps what you can afford (thinking of open source vs. commercial).

My personal experience has been that there is no single software that can do everything and so for me the key has been to identify what I need done and to minimize the number of software I need to accomplish it. This has led me to choices that are not common to my peers and has also left me to find my own solutions, not dreawing so much from other pesons experience (thank heavens for sites such as stackexchange)

So stick to what you know as long as it can do what you want but always keep an eye out for new solutions and try to figure out what others are doing that may impress you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .