Sophie Sperner
Sophie Sperner

Reputation: 4546

Gnuplot, graph line colour

In gnuplot, I draw a graph like below:

gnuplot> set title "Performance analysis" font ", 16"
gnuplot> set xlabel "Array size" font ", 14"
gnuplot> set ylabel "Time, milliseconds" font ", 14"
gnuplot> set xrange [0:25]
gnuplot> set yrange [0:6300]
gnuplot> set xtics (5, 9, 11, 13, 15, 17, 19, 21, 23)
gnuplot> set ytics (88, 296, 433, 835, 1067, 1516, 2592, 3920, 6214)
gnuplot> set style line 1 linecolor rgb "blue"
gnuplot> plot "file.dat" using 1:2 title "Graph" with lines

it is fine, but the line colour of my graph is still red (default), could you please help me to set it to the blue colour.

Upvotes: 2

Views: 8026

Answers (1)

andyras
andyras

Reputation: 15910

You are missing one argument to the plot command; try

plot "file.dat" using 1:2 title "Graph" with lines ls 1

ls 1 tells gnuplot to use linestyle 1. If you don't specify the line style, it will just cycle through its defaults. While you're at it, you could set

set style data lines

before plotting. That way gnuplot will plot data with lines, and you don't have to specify it in each plot command. If you're only plotting one line, though, you can do it all in one command:

plot "file.dat" using 1:2 title "Graph" with lines lc rgb 'blue'

Upvotes: 7

Related Questions