Design, construction, tuning of spectroscopes
Information and discussion about softwares (telescope remote, autoguiding, acquisition, spectral processing ...)
need help with GnuPlot. I'm trying to plot multiple spectra but shift each of them on the Y-axis. I'm using the command "using 1:($2+n)" but this doesn't work... what I'm missing in the syntax there???
Here is the result I get:
nova.jpg (85.42 KiB) Viewed 5174 times
And here is the code of my script, based on ISIS std2.gnu:
#============================================================
# GnuPlot script : STD_novaX.GNU
#============================================================
# Plot nova spectra (one per night) in one graph
#============================================================
# --------------------------------------
# Setting
# --------------------------------------
set xlabel "Wavelength (A)"
set ylabel "Relative intensity"
set xrange [3676:7350]
set yrange [0:15]
set tmargin 2
set title 'Nova Del 2013 - 20130814-20(TV85 + Alpy 600 + Atik460; O. Thizy)' offset 0,-0.5
set terminal push
# ------------------------------------
# Plot on the computer screen
# ------------------------------------
set terminal windows "Arial" 9
plot '_novadel2013_20130814_993_othizy.dat' using 1:($2+10) title "20130814_993" with lines lc rgb 'blue',\
'_novadel2013_20130815_913_othizy.dat' using 1:($2+8) title "20130815_913" with lines lc rgb 'red',\
'_novadel2013_20130816_862_othizy.dat' using 1:($2+6) title "20130816_862" with lines lc rgb 'green',\
'_novadel2013_20130817_988_othizy.dat' using 1:($2+4) title "20130817_988" with lines lc rgb 'yellow',\
'_novadel2013_20130818_874_othizy.dat' using 1:($2+2) title "20130818_874" with lines lc rgb 'purple',\
'_novadel2013_20130819_985_othizy.dat' title "20130819_985" with lines lc rgb 'black'
# ------------------------------------
# Plot on a PNG file
# ------------------------------------
set terminal png small size 1200,800
set output 'nova.png'
replot
# ------------------------------------
# Finalize
# ------------------------------------
set output
set terminal pop
reset
set xlabel 'velocity (km/s) at ref lambda=5875.97A'
set ylabel 'Relative intensity'
set title 'RR lyrae'
set xrange [-200:1200]
set yrange [0:15.5]
set key on outside
plot 'data0.dat' u ($1):($2 + 13.5) title 'JD=2456418.4762 ph=0.7502' with lines
replot 'data1.dat' u ($1):($2 + 13.2) title 'JD=2456418.4797 ph=0.7564' with lines
replot 'data2.dat' u ($1):($2 + 12.9) title 'JD=2456418.4832 ph=0.7625' with lines
it didn't work because I was calling the script, in GnuPlot (call...). There is then a conflict between $2 as the script second parameter and $2 as the second column data.
So you have to use column(2) instead of $2 in the using subparamter of the plot function... It now works!
#============================================================
# GnuPlot script : STD_novaX.GNU
#============================================================
# Plot nova spectra (one per night) in one graph
#============================================================
cd 'D:\\Acquisitions\\20130819 Revel Alpy TV85\\'
# --------------------------------------
# Setting
# --------------------------------------
set xlabel "Wavelength (A)"
set ylabel "Relative intensity"
set xrange [3800:7350]
set yrange [0:15]
set tmargin 2
set title 'Nova Del 2013 - 20130814-20(TV85 + Alpy 600 + Atik460; O. Thizy)' offset 0,-0.5
set terminal push
# ------------------------------------
# Plot on the computer screen
# ------------------------------------
set terminal windows "Arial" 9
plot '_novadel2013_20130814_928_othizy.dat' u 1:(column(2) + 10) title "20130814_928" with lines lc rgb 'blue',\
'_novadel2013_20130815_913_othizy.dat' u 1:(column(2) + 8) title "20130815_913" with lines lc rgb 'red',\
'_novadel2013_20130816_862_othizy.dat' u 1:(column(2)+6) title "20130816_862" with lines lc rgb 'green',\
'_novadel2013_20130817_988_othizy.dat' u 1:(column(2)+4) title "20130817_988" with lines lc rgb 'gray',\
'_novadel2013_20130818_874_othizy.dat' u 1:(column(2)+2) title "20130818_874" with lines lc rgb 'purple',\
'_novadel2013_20130819_985_othizy.dat' title "20130819_985" with lines lc rgb 'black'
# ------------------------------------
# Plot on a PNG file
# ------------------------------------
set terminal png small size 1200,800
set output 'nova.png'
replot
# ------------------------------------
# Finalize
# ------------------------------------
set output
set terminal pop
reset