0
votes

Suppose I have a series of important data that show some measure at 0; how can I plot those data with gnuplot, see those measures as a line, and without receiving the following error: Warning: empty y range [0:0], adjusting to [-1:1].

Here's a MWE:

plot '-'
input> 1 0
input> 2 0
input> 3 0
input> e

Here is what I see:

enter image description here

I was expecting a line with three data points, from 1,0 to 3,0. How can I make that?

1
Your other two points are hidden by the vertical plot borders. If you want the horizontal range to extend beyond that of the input x coordinates you can either set an explicit range (set xrange [0:4]) or request extra whitespace separating the data points from the plot borders (set offsets 1,1,1,1). - Ethan

1 Answers

1
votes

As @Ethan Merritt has mentioned in his comment, you should / need to set the plot range explicitly. My preferred way is to include it in the plot instruction:

plot[0:4][-.5:+.5] '-'

would be a good fit for your sample data. Other ways of setting the range are possible, as Ethan says.

In order to get a line rather than points, you again need to instruct gnuplot, simply telling it with lines, or if you prefer a shorthand, w l:

plot[0:4][-.5:+.5] '-' w l

gives you, for your sample data:

enter image description here