Credits Overview Plotting Styles Commands Terminals

1D sampling (x or t axis)

By default, computed functions are sampled over the entire range of the plot as set by a prior set xrange command, by an x-axis range specifier at the very start of the plot command, or by autoscaling the xrange to span data seen in all the elements of this plot. Points generated by the pseudo-file "+" are sampled over the current range of the t axis, which may or may not be the same as the range of the x axis.

Individual plot components can be assigned a more restricted sampling range.

Examples:

This establishes a total range on x running from 0 to 1000 and then plots data from a file and two functions each spanning a portion of the total range:

      set xrange [0:1000]
      plot 'datafile', [0:200] func1(x), [200:500] func2(x)

This is similar except that the total range is established by the contents of the data file. In this case the sampled functions may or may not be entirely contained in the plot:

      set autoscale x
      plot 'datafile', [0:200] func1(x), [200:500] func2(x)

The plot command below is ambiguous. The initial range [0:10] will be interpreted as applying to the entire plot, overriding the previous xrange command, rather than applying solely to the sampling of the first function as was probably the intent:

      set xrange [0:50]
      plot [0:10] f(x), [10:20] g(x), [20:30] h(x)

To remove the ambiguity in the previous example, either insert the keyword sample to indicate that [0:10] is a sampling range rather than an axis range or add a sampling increment field (following a second colon) in the range specifier. This works because a full range specifier [min:max:increment] cannot be mis-parsed as an axis range. If the increment field is empty then the increment defaults to (min-max/samples), so all three variants below produce the same result.

      set samples 100
      plot sample [0:10]     f(x), [10:20] g(x), [20:30] h(x)
      plot        [0:10:0.1] f(x), [10:20] g(x), [20:30] h(x)
      plot        [0:10:]    f(x), [10:20] g(x), [20:30] h(x)

This example shows one way of tracing out a helix in a 3D plot

      set xrange [-2:2]; set yrange [-2:2]
      set angle degrees
      splot [phi=1:720:2] '+' using (cos(phi)):(sin(phi)):(phi)