I have an application that produce log like that:

14:48:16, 41.0
14:50:01, 40.0
14:54:01, 41.0
14:54:04, 40.0
14:55:10, 41.0
14:55:22, 40.0
15:00:13, 41.0

It is current time and the measured temperature. The application writes a line to the log file when temperature changes.

I want plot a temperature graph via gnuplot and I tried that:

set xdata time
set timefmt "%H:%M:%S"
set yrange [30:50]
set xrange ["14:40":"16:50"]
plot 'temp.csv' using 1:2 with lines

It shows a graph like that:


But I want the lines are horizontal and form a step at time when the temperature changes. The result should look like the blue line:

desired graph

How can I force gnuplot to do that? I can do that vi the log preprocessing but I want to do that only via gnuplot only if possible.

  • 3
    replace with lines by with steps.
    – meuh
    Feb 20, 2018 at 20:51
  • Ouch, that is so easy. I was blind when I tried to find it. Thanks. Feb 20, 2018 at 20:57
  • 1
    @ZabojCampula: Post it as an answer
    – Thor
    Feb 20, 2018 at 21:41

1 Answer 1


Gnuplot has bunch of styles that can be used for displaying data. The with lines option connects each data point with lines. It is suitable to smoothly varying data.

Data containing the time and value that is valid since this time till next change is can be plot as a histogram. Gnuplot plots a histogram if the option with steps is specified. So the complete command is

plot 'temp.csv' using 1:2 with steps

Nice documentation and examples are at http://lowrank.net/gnuplot/intro/style-e.html.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .