Search code examples
gridgnuplotz-axis

How to make vertical lines in the planes zx and z and gnuplot


I need a little help. I'm making a three surfaces together in gnuplot, but I need to place the vertical and horizontal grids for the Z axis on the back of the surfaces. I've only been able to make the horizontal lines, and I want to add the vertical lines, some suggestions to do this in my code

Thank you very much.

set key outside
set rmargin at screen 0.6
set lmargin at screen 0.18
set title 'Gnuplot surfaces'
set key 
set pm3d depthorder hidden3d 1
set hidden3d offset 0
set xlabel "X"
set xrange [ -4.0000 : 4.0000 ] noreverse nowriteback
set mxtics 4
set ylabel 'Y'
set yrange [ -4.0000 : 4.0000 ] noreverse nowriteback
set mytics 4
set zlabel "Z" 
set zrange [-1.000: 1.000] noreverse nowriteback
set mztics 4
set surface
set isosamples 25
unset colorbox
set ticslevel 0
set grid ztics xtics ytics lt 2 lc rgb "black"
set border 4095
set view 43, 32
a(x,y)= sin(sqrt(x**2+y**2)) / sqrt(x**2+y**2)
b(x,y)= x**3*y**2
c(x,y)= sin(x) * cos(y)
splot a(x,y) lc rgb 'gray' linewidth 2, b(x,y) lc rgb 'red' linewidth 0.5, c(x,y) lc rgb 'blue' linewidth 1

enter image description here


Solution

  • First, add a data block (gnuplot 5.0 or greater) for all the grid lines as vectors:

    $data << EOD
    -4 -3 -1 0 0 2
    -4 -2 -1 0 0 2
    -4 -1 -1 0 0 2
    -4  0 -1 0 0 2
    -4  1 -1 0 0 2
    -4  2 -1 0 0 2
    -4  3 -1 0 0 2
    -3  4 -1 0 0 2
    -2  4 -1 0 0 2
    -1  4 -1 0 0 2
     0  4 -1 0 0 2
     1  4 -1 0 0 2
     2  4 -1 0 0 2
     3  4 -1 0 0 2
    EOD
    

    Now, just create an arrow style as black with no heads and add this 'file' to the plot with vectors and no title.

    set style arrow 1 nohead lc 'black'
    replot "$data" with vectors arrowstyle 1 title ""
    

    If you do not have gnuplot 5.0 or greater, put the data block in a file and just plot the file.