しょんぼり技術メモ

まいにちがしょんぼり

Drawing horizontal lines in specified range with Gnuplot

to draw horizontal lines with Gnuplot, define a function like this:

step(x,from,to,y)=( (from <= x) && (x <= to) ) ? y : 0/0
# draw y=7, horizontal line, in range: 5<=x<=7
plot step(x, 5, 10, 7)

points are:

  • gnuplot abandons drawing if NaN is given. this is useful when you don't want to draw a line in specified range.
  • specifying keyword "notitle" on the graph, the title will not shown in the legend.