1

I'm trying to generate a graph with gnuplot but it seems that it doesn't show the correct values: Data are:

03/18/2014 15:00:50                32,4
03/18/2014 14:00:48                32,4
03/18/2014 13:00:48               32,42
03/18/2014 12:00:44                32,4
03/18/2014 11:00:42                122,2
03/18/2014 10:00:47                22,4
03/18/2014 09:00:37                53,9
03/18/2014 08:00:35                14,2

The sh is:

#!/usr/bin/gnuplot

set title "Plot x^2"
set terminal png
set output "output.png"

set xlabel "X"
set ylabel "Y"
#set datafile sep ','
set xdata time
set timefmt '%m/%d/%Y %H:%M:%S'
plot 'pepe.csv' using 1:2 with lines

It shows me:

6
  • What do you want it to look like? Be specific. Commented Mar 18, 2014 at 15:05
  • Thanks. I would like that the line have the second value (32,4-32,4-32,42-32,4-28,7-23-6)....The X asys is fine but the second value don't shows the correct values Commented Mar 18, 2014 at 15:28
  • I'm not where those numbers are coming from, is it one column minus the other? Can you edit the question to make it clearer? Commented Mar 18, 2014 at 15:33
  • I edit the data. The graph is simply a time graph of a tablespace size. Thanks Commented Mar 18, 2014 at 15:40
  • It looks like gnuplot is having trouble parsing both columns of data. Applying the setting set decimalsign ',' may help. Commented Mar 18, 2014 at 15:45

1 Answer 1

3

@andyras' suggestion of set decimalsign ',' is helpful but if you have a space in the time format then it counts as more than one column. Quoting the documentation:

Each set of non-blank characters in the timedata counts as one column in the using n:n specification. Thus 11:11 25/12/76 21.0 consists of three columns. To avoid confusion, gnuplot requires that you provide a complete using specification if your file contains timedata.

This means that you need to change using 1:2 to using 1:3.

Using your original data, this script works for me:

#!/usr/bin/gnuplot

set title "Plot x^2"
set terminal png
set output "output.png"

set xlabel "X"
set ylabel "Y"
set decimalsign ','
set timefmt '%m/%d/%Y %H:%M:%S'
set xdata time

plot 'decimal.txt' u 1:3 with lines

Output: image showing correct plot

Alternatively, you could use a different data separator in your datafile, such as a , and the time will only count as one column. To do this you add the line set datafile sep ',' to your script.

edit: you might want to also consider using the pngcairo terminal (set term pngcairo), as it looks a lot better:

plot using pngcairo

Sign up to request clarification or add additional context in comments.

2 Comments

Good guess :) With the pngcairo terminal the graph looks much better i.sstatic.net/XkkPK.png
@Christoph I've included your masterpiece

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.