Skip to content

Instantly share code, notes, and snippets.

@fearofcode
Created February 25, 2013 22:59

Revisions

  1. Warren Henning created this gist Feb 25, 2013.
    25 changes: 25 additions & 0 deletions plot_series.gp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@

    # resulting image: http://i.imgur.com/E5CsReh.png

    # create a 1680x1050 image using Arial, 12pt
    set terminal pngcairo enhanced font "arial,12" fontscale 1.0 size 1680, 1050

    # write to the file 'multiplot_test.png'
    set output 'multiplot_test.png'

    # turn key off since we will be plotting many different
    unset key

    # tell gnuplot we are plotting time data formatted like Year-month-day
    set xdata time
    set timefmt "%Y-%m-%d"

    # set colors for each segment we are drawing
    set style line 1 linewidth 3 linecolor rgb "green"
    set style line 2 linewidth 3 linecolor rgb "black"
    set style line 3 linewidth 3 linecolor rgb "red"

    # plot the input file using the line styles defined above
    plot 'test.dat' i 0 u 1:2 w lines ls 1,\
    'test.dat' i 1 u 1:2 w lines ls 2,\
    'test.dat' i 2 u 1:2 w lines ls 3
    21 changes: 21 additions & 0 deletions test.dat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    "trade 1"
    2012-01-08 20
    2012-01-09 21
    2012-01-10 22
    2012-01-11 23
    2012-01-12 22


    "out of market"
    2012-01-12 22
    2012-01-13 23
    2012-01-14 22
    2012-01-15 21
    2012-01-16 22


    "trade 2"
    2012-01-16 22
    2012-01-17 21
    2012-01-18 15
    2012-01-19 13