gnuplot で軸に並行な線を引く

x軸に並行な線を引く場合

これはかなり簡単で、定数の関数を定義してやれば良いです。

unset grid
set terminal pdfcairo enhanced color font "Helvetica,18"
set output "x-axis.pdf"
set xlabel 'xlable'
set ylabel 'ylable'
set xrange [:]
set yrange [:]
set ytics 0.5
f1(x) = 2.0
plot f1(x)  title "" with  lines lc rgb "blue" lt 1 lw 2
unset terminal

y軸に並行な線を引く場合

媒介変数を使う方法と、愚直にarrowを使う方法があります。ここでは 媒介変数を使う方法を述べます。

unset grid
set terminal pdfcairo enhanced color font "Helvetica,18" 
set output "y-axis-1.pdf"
set xlabel 'xlable' 
set ylabel 'ylable' 
set xrange [:]
set yrange [:]
set xtics 0.5
set ytics 0.5
set parametric
set trange [-0.5:0.5]
cnst = 2
plot cnst,t with lines title "" lw 2

unset terminal

arrowを使う場合

arrowを使う場合は、軸に並行な線だけでなく任意の線を引くことができます。

unset grid
set terminal pdfcairo enhanced color font "Helvetica,18"
set output "arrow.pdf"
set xlabel 'xlable'
set ylabel 'ylable'
set xrange [:]
set yrange [0:4]
set ytics 1.0
f1(x) = 2.0
set arrow from  1.0,0.0 to 1.0,4.0 nohead lw 2 dt (10,5) lc rgb "red"

plot f1(x)  title "" with  lines lc rgb "blue" lt 1 lw 2
unset terminal