dorien
dorien

Reputation: 5407

Plotting two splots in one gnuplot

I currently draw a helix with some points in a gnuplot script. Now I want to draw a second helix inside the other helix, with formula: splot [t=-1.5*pi:6*pi] sin(t),cos(t),t*0.23246067325

However, it doesn't seem to work if I just add the command to the script. Is there a specific way to do it?

reset
clear
set parametric
unset key
unset tics
unset border 

set termoption dashed
set termoption dashlength 2

set object rectangle from screen 0,0 to screen 1,1 behind fillcolor rgb 'white' fillstyle solid noborder

set style line 4 lc rgb 'black' pt 7
set style line 7 lc rgb 'royalblue' pt 7 ps 10

splot [t=-1.5*pi:6*pi] sin(t),cos(t),t*0.23246067325 ls 4, '-' w p ls 7,  '-' w p ls 7
0.0 1.0 2.9211869733608857 #G#
e
-1.0 0.0 4.016632088371217 #E#
e

Upvotes: 1

Views: 322

Answers (1)

maij
maij

Reputation: 4218

Variable t is used for 2D plots. For 3d plots (splot) use u and v instead.

It seems that you only need u, so I have removed your "[t=-1.5*pi:6*pi]" and replaced it by set urange [-1.5*pi:6*pi] before entering the splot command:

(You have specified only one helix, so I have scaled the first one a little bit to generate a second one. And the set termoption dashlength 2 did not work for me, so I removed it.)

reset
clear
set parametric
unset key
unset tics
unset border

set object rectangle from screen 0,0 to screen 1,1 behind fillcolor rgb 'white' fillstyle solid noborder

set style line 4 lc rgb 'black' pt 7
set style line 7 lc rgb 'royalblue' pt 7 ps 10

set urange [-1.5*pi:6*pi]

splot sin(u), cos(u), u*0.23246067325 ls 4 ,\
      0.8*sin(u), 0.8*cos(u), u*0.23246067325 ls 1 ,\
      '-' w p ls 7,  \
      '-' w p ls 7
0.0 1.0 2.9211869733608857 #G#
e
-1.0 0.0 4.016632088371217 #E#
e

This generates the following output:

enter image description here

Upvotes: 2

Related Questions