0

I have a dataset of the form

x,y,z,zerr

and want to generate a three dimensional plot of it including error bars on the values for z. So what I want is a plot like

splot "datafile.dat" using 1:2:3

which gives a regular 3D plot, but it should also include error bars. I have tried using

splot "datafile.dat" using 1:2:3:4 with errorbars

but this only generates the same plot again, not showing any error bars. Is there a way to do this in Gnuplot? If no, is there a way to do it in Python using matplotlib? If so, I might be using it instead.

2 Answers 2

1

Gnuplot does have a 3D plot style zerror that includes error ranges drawn as a shaded region rather than individual bars. Otherwise you would have to construct the points, lines, and error bars in separate plot clauses. Note that the input data specification for 3D vectors is x y z delta-x delta-y delta-z Here is a figure that shows all of these. I have forced the x values to either 0 or 1 for the purpose of separating the zerror variant from the others.

set view 60, 120
set xyplane at 0
set grid x y z vertical linewidth 1
set yrange [200:500]
set xrange [1.5 : 0]
set style fill transparent solid 0.25

set style arrow 1 heads size screen 0.005, 90
set style arrow 1 lc "blue" lw 1.5

splot 'DATA' using (0):2:3:4 with zerror title "with zerror", \
      '' using (1):2:3 with lines title "with lines", \
      '' using (1):2:3 with points pt 7 lc "black" title "with points", \
      '' using (1):2:($3-$4):(0):(0):(2.*$4) with vector as 1 title "with vectors"

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

1

When I checked gnuplot help (5.2.8), I was surprised that I couldn't find something like zerrorbar. Maybe for some reason? Independent of whether it exits or I just haven't found it, you can do it yourself using with vectors. Maybe the following example is what you are looking for.

Code:

### zerrorbars via with vectors
reset session

$Data <<EOD
0    0.5  0    0.2
1    0    0    0.3
0    1    0    0.4
0.5  1    1    0.5
EOD

unset key
set ztics 0.5
set style arrow 1 heads size 0.01,90 lc "red"

splot $Data u 1:2:3 w p pt 7 lc "black", \
      '' u 1:2:($3-$4):(0):(0):(2*$4) w vectors as 1
### end of code

Result:

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.