Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

x-axis value on gnuplot

I am playing around with gnuplot.My data set looks like this.

1     0.530000  0.510000
2     0.420000  0.310000
4     0.400000  0.160000
8     0.390000  0.070000
16    0.390000  0.040000
32    0.310000  0.020000
64    0.170000  0.020000
128   0.070000  0.000000
256   0.030000  0.000000
512   0.020000  0.000000
1024  0.000000  0.000000

My gnuplot file is as given blow.

#!/usr/bin/gnuplot
reset
set terminal png

set ylabel "time in ms"

set xlabel "k"

set title "update every kth element"
set key reverse Left outside
set grid

set style data linespoints

set output 'cache_access.png'
plot "time_mem_access.dat" using 1:2 title "cache access 1", \
      ""                   using 1:3 title "cache access 2"

The graph that I got looks like below.

enter image description here

My problem is that I want the x-axis to show the exact values in the first column

i.e 1,2,4,8,16,32,64 etc.

I can't find any documentation online on how to get exactly this done.

like image 505
liv2hak Avatar asked Dec 07 '22 07:12

liv2hak


1 Answers

Instead of calling:

plot "time_mem_access.dat" using 1:2 title "cache access 1", \
      ""                   using 1:3 title "cache access 2"

You can try:

plot "time_mem_access.dat" using 1:2:xtic(1) title "cache access 1", \
      ""                   using 1:3:xtic(1) title "cache access 2"

Which will give you the following plot: enter image description here

However you might want to take a log of the x values:

plot "time_mem_access.dat" using (log($1)):2:xtic(1) title "cache access 1", \
      ""                   using (log($1)):3:xtic(1) title "cache access 2"

Which would give you: enter image description here

like image 144
SidR Avatar answered Dec 18 '22 17:12

SidR