1

I'm currently trying to produce graphs using gnuplot within a python script but I'm getting this error:

line 0: Can't plot with an empty x range!

I don't know why my xrange isn't being recognised because I have included it in my code as shown below along with the rest of my gnuplot code within my python script.

### GNUPLOT CODE ####  
g = Gnuplot.Gnuplot() 
g('set terminal png')

# Graph layout settings
g('set term png size 1200, 800')
g('set lmargin 8')
g('set rmargin 4')
g('set tmargin 3')
g('set bmargin 3')

# Set the name of the output file
g('set output "' + outputFile + '"')

# Format the time
g('set timefmt "%H:%M:%S"')
g('set format x "%H:%M:%S"')

# Set title and labels of the graph. Specify where the x axis starts and ends.
g('set title "' + title + '"')
g('set xlabel "time"')
g('set ylabel "percent"')
g('set xrange ["15:43:59":"15:48:56"]')

# Use the .txt file specified by the user to create the graph
g('plot "' + inputFile + '" using 1:3 title "user" with lines')

1 Answer 1

2

You're only missing a

g('set xdata time')

Therefore, gnuplot tries to parse the strings a numbers and ends up with set xrange [15:15], which is an empty range. You'll observe the same error message with

set xrange ["15:43:59":"15:48:56"]
plot x
Sign up to request clarification or add additional context in comments.

1 Comment

Can't believe it was only 1 line of code I was missing which was causing it to not work. Thanks for helping!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.