Gnuplot: multiple plot with Y axis shift ?

Design, construction, tuning of spectroscopes
Information and discussion about softwares (telescope remote, autoguiding, acquisition, spectral processing ...)
Post Reply
Olivier Thizy
Posts: 370
Joined: Sat Sep 24, 2011 10:52 am
Location: in the french Alps...
Contact:

Gnuplot: multiple plot with Y axis shift ?

Post by Olivier Thizy »

Hello,


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
nova.jpg (85.42 KiB) Viewed 5173 times

And here is the code of my script, based on ISIS std2.gnu:

Code: Select all

#============================================================
# 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

Thank for the help!
Olivier
Thierry Lemoult
Posts: 136
Joined: Thu Sep 29, 2011 9:08 am

Re: Gnuplot: multiple plot with Y axis shift ?

Post by Thierry Lemoult »

Hello Olivier

Here one sample of my gnu plot file.

Code: Select all

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
Olivier Thizy
Posts: 370
Joined: Sat Sep 24, 2011 10:52 am
Location: in the french Alps...
Contact:

Re: Gnuplot: multiple plot with Y axis shift ?

Post by Olivier Thizy »

Thierry,


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! :-)


Here is the proper code:

Code: Select all

#============================================================
# 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


and the result on the nova Del 2013:
nova.jpg
nova.jpg (154.74 KiB) Viewed 5141 times

Cordialement,
Olivier Thizy
Post Reply