Search code examples
gnuplot

How to set an arbitrary z value for XY pairs in a series with gnuplot


I have a csv file with multiple XY data pairs. Each data pair is separated by one hour. I would like to graph these data pairs in one 3D graph so I can leverage the depth to better visualize the graph. can I set an arbitrary Z value for each XY data pair, where Z=hours? I understand I could alter the CSV file to have a third column for each pair, but in my case it would be faster to simply arbitrate a z value for each pair (if possible). Thank you.

For example, 1:2 is hour 1, and 3:4 is hour 2, and so on...


Solution

  • Gnuplot treats treats the row number as column 0, so a commands

    set datafile separator comma
    splot "data.csv" using 1:2:0
    

    would use the first two entries on each line as an x,y pair and assign the row number as z. If by "arbitrary" you mean "some constant I pick beforehand", then you can place that value inside parentheses to indicate it is a numerical value rather than a column number:

    FOO = 123.456
    splot "data.csv" using 1:2:(FOO)