Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have some time-series data I want to visualize as 2d plot.

The input is ISO-date-format and value separated by space, one record per line:

2010-10-21 23
2010-10-22 32
etc.

The output should be a nice looking 2d plot. Basic requirements:

  • output to a X11 window (as preview) and to a png file
  • x-axis has to understand the dates and naturally scale the data, e.g. a gap between 3 days should be three times as long as a gap between 1 day
  • should be callable from a script
  • nice output and convenient to use

Bonus:

  • svg output

I tried gnuplot and it works - it has some date support:

gnuplot> set xdata time
gnuplot> set timefmt "%Y-%m-%d"
gnuplot> plot "test.dat" using 1:2

But I have some problems with gnuplot:

  • with default settings plots look very ugly
  • it is difficult to find stuff in the manual - e.g. when plotting points how do I use small filled circles instead of the default '+' sign?
  • the gnuplot shell is a pain in the neck - it does not use readline, it is broken, command completion is a joke, I don't know how to enable vi shortcuts - or if they are supported, what about reverse search etc.

Thus my question: What are the alternatives for visualizing time-series data?

Or am I overstating the gnuplot issues?

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

RRDTool's whole purpose of existence is plotting time series data, but it's primarily meant for automated graphing and may not be the best fit for your needs.

That said:

  • It can output in either PNG or SVG, but has no preview functionality.
  • Time-scaling is built in.
  • Easily scripted (command line access or libraries in many scripting languages).
  • Output can be made to look pretty decent .

RRDTool graph

share|improve this answer
    
Sounds interesting, missing preview is no that bad - just generating a png and using an image viewer side by side should be ok. Could you give an example of simple command line call of this tool? –  maxschlepzig Jan 29 '11 at 10:30
    
    
Basically you run rrdtool create ... once to set up the RRD db, rrdtool update ... once per piece of data and rrdtool graph ... to generate a graph. –  Kowh Jan 29 '11 at 14:41
add comment

R is better at this sort of thing because:

  1. It's a complete programming environment, with C and Fortran-compatible extension APIs, so there is literally nothing you can't make it do.

  2. Many have already contributed their solutions to common problems to the CRAN: Comprehensive R Archive Network.

  3. There are many books on time series analysis and R in general.

R has everything you asked for:

  • Outputs to X11, PNG, or (with an add-on) SVG

  • Filled circles for plot points: pass pch=19 or pch=20 to par() or points(). There are many other plot point symbols predefined, plus all of Unicode if you're using a font with Unicode support.

  • Time-aware charting: if the built-in ones don't have the scaling you want, you can build anything you need with R's plotting primitives

  • Callable from a script: use a #!/usr/bin/Rscript shebang line on your R program file

  • Nice and convenient: There are GUI frontends, if you like, and if you don't like, the default command-driven environment has a lot of nice features, like the ability to see the R source code of many builtin operations, which helps to learn how the system is put together. (Yes, much of R is written in R!)

  • Pretty plots: Antialiasing is the default if R is built against Cairo, which it will be if it's a recent build on Linux. Old versions of R may not have AA built in. For an idea of the capability of R if you put a bit of time into it, check this out:

    (Click image for article describing it.)

Regarding the gnuplot command line, you can build it to support GNU readline, BSD libedit, or as a fall-back, a custom built-in command line editing scheme. (This according to p.20 of the manual.) I have gnuplot 3.7 on one machine and 4.0 on another, and they're both built with readline. Perhaps you have a special masochist's/minimalist's build? :)

share|improve this answer
    
In particular, the zoo package has lots of functions to deal with time series. PS: about your point 1: being Turing complete does not mean that a language can do everything. ;) –  nico Jan 29 '11 at 1:29
    
Didn't say anything about Turing, but clarified point 1 anyway. :) –  Warren Young Jan 29 '11 at 1:35
    
I started using R for all my statistics and plotting at work, it's great! –  jsbillings Jan 29 '11 at 1:42
    
Good hint about libedit. Well, I am using the default gnuplot package on Ubuntu 10.04. It seems that it is linked against libedit which seems to support vi mode at least. But command completion is just minimal (works only for filenames) and not with gnuplot commands, i.e. it is basically useless (this is not the fault of libedit). –  maxschlepzig Jan 29 '11 at 2:07
    
@Warren: mine was a (joking) remark about the "can do anything". R can't do coffee, just to say one :P –  nico Jan 29 '11 at 19:26
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.