Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNUplot - plot data file (simple X and Y columns) - setting suitable color and scale on a figure

Tags:

gnuplot

I have a simple file with two columns:

1 0.005467
2 0.005333
3 0.005467
4 0.005467
5 0.005600
6 0.005600
7 0.005467
8 0.005467

In the first column I have the x-axis values, while on the second column I have y-axis values. I would like to plot a figure of this data. I wrote a gnuplot script for this:

#!/usr/bin/gnuplot

set xlabel "test"
set ylabel "value"
set grid ytics lt 0 lw 1 lc rgb "#bbbbbb"
set grid xtics lt 0 lw 1 lc rgb "#bbbbbb"
set autoscale
set terminal postscript portrait enhanced mono dashed lw 1 'Helvetica' 14
set style line 1 lt 1 lw 3 pt 3 linecolor rgb "red"
set output 'out.eps'
plot 'data.txt' using 2:1 w points title "tests"

And, the output:

enter image description here

But of course, as a newbie in gnuplot, I have some troubles:

  1. How to change the crosses on the fingure into dots?
  2. How to change the color of the dots, to let's say, red? ( my command in my gnuplotscript seems not to work at all ...)
  3. For the first test the adequate, accurate, exact value is 0.005467 but on my figure it doesnt look like so... I would like to place the dot on my figure for the first, second, third, (so on) test on the exact place, where is appropriate value.
  4. How to add a grid to my figure? - SOLVED
  5. How to get rid of the ugly text: 'data.txt' using 1:2 and replace it with a legend? - SOLVED

EDIT (SOLVED ISSUE NO 5)

plot 'data.txt' using 1:2 w points title "tests"

EDIT (SOLVED ISSUE NO 4)

set grid ytics lt 0 lw 1 lc rgb "#bbbbbb"
set grid xtics lt 0 lw 1 lc rgb "#bbbbbb"
like image 244
yak Avatar asked Nov 02 '22 08:11

yak


1 Answers

You should read a bit in the documentation about all your commands!

Several remarks:

If you want colored points, you shouldn't use the mono (i.e. the monochrome) option, but rather color.

Your definition of the line style is correct, but in order to use it you must use linestyle 1 when plotting. Otherwise the linetype 1 is used. Compare:

set style line 1 lt 1 lw 3 pt 3 linecolor rgb "red"
plot x, 2*x linestyle 1

In order to see all the dots of a terminal, use the test command:

set terminal postscript eps enhanced color dashed lw 1 'Helvetica' 14
set output 'test.eps'
test
set output

You see, that for filled dots you must use pt 7.

I'm sure, that the points are shown at the correct values. Use

set ytics add (0.005467)

to see this.

like image 61
Christoph Avatar answered Nov 08 '22 03:11

Christoph