Search code examples
gnuplotinlining

Gnuplotting multi-plot data without a textfile


I've just read Gnuplotting data without a textfile, and I want to do the same thing, but with a "multi-plot". I currently have:

plot 'data.csv' using 1:3:2:6:5:7:xticlabels(8) with candlesticks title 'Quartiles' whiskerbars, \
  ''         using 1:4:4:4:4:4 with candlesticks lt -1 notitle

and I want to inline the data in data.csv.


Solution

  • This is easy enough:

    set multiplot layout 1,2
    plot '-' u 1:2
    1 2
    2 3
    3 4  
    e
    
    plot '-' u 1:2
    2 3
    3 4
    4 5
    e
    

    Note that inline data is not really particularly happy with the '' pseudofile. You would actually need to include your entire data again at that point. So, If you want 2 traces on the same subplot of a multiplot:

    set multiplot layout 1,2
    plot '-' u 1:2, '-' u 1:3
    1 2 3
    4 5 6
    7 8 9
    e
    1 2 3
    4 5 6
    7 8 9
    e
    
    plot '-' u 1:($2*$3)
    1 2 3
    4 5 6
    7 8 9
    e
    

    This ends up being the same thing as if you had a datafile data.txt:

    #data.txt
    1 2 3
    4 5 6
    7 8 9
    

    and plotted it with this (much simpler) script:

    set multiplot layout 1,2
    plot 'data.txt' u 1:2, '' u 1:3
    plot '' u 1:($2*$3)