1

Currently, I'm trying to create a 3d parametric graph similar to this:

which can be found here: http://gnuplot.sourceforge.net/demo/surface1.html.

With script here: http://gnuplot.sourceforge.net/demo/surface1.17.gnu

My graph looks like this:

enter image description here

and I'm using this:

set datafile separator ","
set parametric
x0 = 0 
x1 = 1
x2 = 2
splot 'January5.csv' u x0:1:3 with lines, 'test.csv' u x1:1:2 with lines

Obviously my graph is lacking in comparison. I really like the ability of the first graph in plotting along the x-axis. I've been trying to replicate this, but have been failing so far.

eunhealee
  • 189
  • 2
  • 4
  • 13
  • Could you show us a sample of your data, just to know what the three dimensions really are and how z varies as a function of x and y? – chl Jan 26 '12 at 11:08
  • Sure: Z Y 0.158999994 83906.71679 0.160000011 84700.96927 0.174999982 84700.96928 (The first is the Z, the second is the Y, and for the X I want to use an arbitrary number to organize the graphs) – eunhealee Jan 30 '12 at 18:37

1 Answers1

1

You don't really need to rely on parametric if you just want to plot raw data from a file.

With sample data xyz.txt that looks like noisy sinusoidal time-series:

1 0 9.43483356296457
1 0.0204081632653061 10.2281885806631
1 0.0408163265306122 10.9377108185805
...
3 0.959183673469388 10.2733398482972
3 0.979591836734694 10.1662011241681
3 1 10.4628112585751

(First column is an integer values coding x locations, 2nd and 3rd columns are for y and z. I appended the R script I used to generate those data at the end.)

I would simply use

splot 'xyz.txt' using 1:2:3 with impulses

where impulses draws vertical lines from the minimum of z. You can change this bevahior; for example, if you want to start at z=0, you could use

set zrange [-1:12]
set ticslevel 0
zmin = 0
zr(x) = (x==0 ? zmin : x)
splot 'xyz.txt' using 1:2:(zr($3)) with impulses

Note that I used regularly spaced values for y, but that doesn't really matter.

enter image description here

Other variations are possible, of course. Maybe Fence plots with a some-liner or Wall charts might be of further assistance.


R script used to generate xyz.dat:

n <- 50  # number of observation per sequence
k <- 3   # number of sequences
t <- seq(0, 1, length=n)  # sampling rate
xyz <- data.frame(x=rep(1:k, each=n), y=t, z=sin(2*pi*t*2.1)+.25*rnorm(n*k)+10)
write.table(xyz, file="xyz.txt", row.names=FALSE, col.names=FALSE)
chl
  • 27,771
  • 5
  • 51
  • 71
  • I have one problem with my current graph. I need the Y axis to be time formatted (so there aren't breaks from times that don't exist: 9:60-9:99), but Gnuplot isn't recognizing timefmt for more than just seconds. – eunhealee Feb 03 '12 at 20:17
  • Not sure I understand correctly, but with data (min:sec) like this `2:30 3.1 \ 2:35 4.7 \ 6:48 9.4 \ ...`, a command like `set xdata time \ set timefmt "%m:%s"` would work. (But see also http://1.usa.gov/xJP8Zu.) Could you perhaps be more precise? – chl Feb 04 '12 at 09:14