2
votes

I've been trying to graph the following data

1, 2050
2, 21246
3, 208557
6, 20971520
10, 306184192
12, 1.75922E+14

Using gnuplot, using the following ytics.

set ytics ( "1 kb" 1000, \
"10 kb" 10000, \
"100 kb" 100000, \
"1 mb" 1000000, \
"10 mb" 10000000, \
"100 mb" 100000000, \
"1 gb" 1000000000, \
"10 gb" 10000000000.0, \
"100 gb" 100000000000.0, \
"1 tb" 1000000000000.0, \
"10 tb" 10000000000000.0, \
"100 tb" 100000000000000.0, \
"1 pb" 1000000000000000.0, \
"10 pb" 10000000000000000.0 )

I can't get gnuplot to show the minor grid on this graph.

As I want the y axis to be logarithmic, it would be good to show the minor tics.

Between 1000 and 10000, I'd like minor tics every 1000. From 10000 to 100000, I'd like it to be 1e4 and so on.

How does one do this?

1

1 Answers

2
votes

In order to understand the solution, there are some steps involved:

  1. Automatic major tics: All minor tics are drawn

    set yrange [1:100]
    set logscale y
    set mytics 10
    plot x
    

    enter image description here

  2. Manually set major tics: The minor tics aren't drawn

    set yrange [1:100]
    set logscale y
    set ytics ('one' 1, 'ten' 10, 'hundred' 100)
    set mytics 10
    plot x
    

    enter image description here

  3. Overwrite major tics with your own text (note the add): minor tics work!

    set yrange [1:100]
    set logscale y
    set ytics add ('one' 1, 'ten' 10, 'hundred' 100)
    set mytics 10
    plot x
    

    enter image description here

So, in your case it should be enough to use set ytics add ... and set mytics 10. You must also make sure, that you have a major tic every decade (set ytics 10), and also set the yrange manually for that many major tics:

set yrange [1e3:1e16]
set ytics 10
set mytics 10

set ytics add ( "1 kb" 1000, \
"10 kb" 10000, \
"100 kb" 100000,\
"1 mb" 1000000, \
"10 mb" 10000000,\
"100 mb" 100000000,\
"1 gb" 1000000000, \
"10 gb" 10000000000.0,\
"100 gb" 100000000000.0,\
"1 tb" 1000000000000.0, \
"10 tb" 10000000000000.0, \
"100 tb" 100000000000000.0, \
"1 pb" 1000000000000000.0, \
"10 pb" 10000000000000000.0 )

set logscale y
plot 'file.txt'

The result with 4.6.4 is:

enter image description here