Search code examples
gnuplot

Grid in xzplane


I'm having trouble with displaying a grid in the xzplane. I've changed the position of my z-axis like this:

Now I'd like to have a grid like in the xy-plane in my xz-plane, but since I'm rather new to gnuplot, I couldn't find the correct command.


My code looks like this:

set parametric

set xlabel "Abweichung"
set ylabel "Dosis [%]"
set zlabel "Volumen [%]"

set xrange [-1:1]
set yrange [0:100]
set zrange [0:100]

set xtics 0.2
set ytics 10
set ztics 10

set grid 

set border 4095 ls 1 lc rgb "black"

set xtics axis
set ytics axis
set ztics axis

set xzeroaxis lt 1 lw 2 lc rgb "black"
set yzeroaxis lt 1 lw 2 lc rgb "black"
set zzeroaxis lt 1 lw 2 lc rgb "black"

set xyplane 0

splot [t=0:100] 0, t, t

Solution

  • Sadly this is currently not supported by the grid command, a feature request should probably be posted.

    Anyway, as suggested by mgilson you can manually add the grid-lines with for-loops and the set arrow command. For example adding the following two lines:

    set for [x = -10:10:2] arrow from x/10.0, 0, 0 to x/10.0, 0, 100 nohead lt 0
    set for [z = 0:100:10] arrow from     -1, 0, z to      1, 0,   z nohead lt 0
    

    Results in:

    Plot that includes XZ grid

    You may want to rotate the plot with set view. The divide-by-ten is there because floating-point increment doesn't seem to work.

    Or if you wanted the grids to be on the back of the box, do something like this:

    set for [x = -10:10:2] arrow from x/10.0, 100, 0 to x/10.0, 100, 100 nohead lt 0
    set for [z = 0:100:10] arrow from     -1, 100, z to      1, 100,   z nohead lt 0
    
    set for [y = 0:100:10] arrow from     -1,   y, 0 to -1,   y, 100 nohead lt 0
    set for [z = 0:100:10] arrow from     -1,   0, z to -1, 100,   z nohead lt 0
    

    Which results in:

    Plot that includes grid at the back of the two walls of the plot

    A style note

    You can replace:

    set xtics axis
    set ytics axis
    set ztics axis
    
    set xzeroaxis lt 1 lw 2 lc rgb "black"
    set yzeroaxis lt 1 lw 2 lc rgb "black"
    set zzeroaxis lt 1 lw 2 lc rgb "black"
    

    with the equivalent:

    set tics axis
    set zeroaxis lt 1 lw 2 lc rgb "black"