Simon Hessner
Simon Hessner

Reputation: 1837

gnuplot logscale looks the same with every base

I am using gnuplot to plot measured data and I want to focus on the smaller values of x. x is between 0 and ~65 but the most interesting things happen between x = 0 and x = 1. So I use logscale.

But it looks the same with every base I choose:

f(x) = x**2

p(l) = (1-(l/100))**2
e(l) = p(l)**50
g(l) = e(l)*1000*100

set key bottom left


set xtics ("0" 0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 1, 2, 5, 10, 15, 25, 40, 50, 60)
set yrange [0:f(100.5)]
set xlabel "loss rate in %"
set ylabel "successful requests (100% of expected results) in %"

set ytics ("0" f(0), "50" f(50), "75" f(75), "80" f(80), "90" f(90), "100" f(100))

set logscale x 10

plot "collected_$intv.table" using 1:(f(\$2/10))  title "maximum 1 try" lc rgb "red" pt 1 lw 1, \
     "collected_$intv.table" using 1:(f(\$2/10))  notitle w lines  ls 27, \
     "collected_$intv.table" using 1:(f(\$3/10))  title "maximum 2 tries" lc rgb "blue" pt 2 lw 1, \
     "collected_$intv.table" using 1:(f(\$3/10))  notitle w lines  ls 27, \
     "collected_$intv.table" using 1:(f(\$4/10))  title "maximum 3 tries" lc rgb "green" pt 3 lw 1, \
     "collected_$intv.table" using 1:(f(\$4/10))  notitle w lines  ls 27, \
     "collected_$intv.table" using 1:(f(\$5/10))  title "maximum 4 tries" lc rgb "black" pt 5 lw 1, \
     "collected_$intv.table" using 1:(f(\$5/10))  notitle w lines  ls 27, \
     "collected_$intv.table" using 1:(f(\$6/10))  title "maximum 5 tries" lc rgb "red" pt 7 lw 1, \
     "collected_$intv.table" using 1:(f(\$6/10))  notitle w lines  ls 27, \
     "collected_$intv.table" using 1:(f(\$7/10))  title "maximum 6 tries" lc rgb "blue" pt 9 lw 1, \
     "collected_$intv.table" using 1:(f(\$7/10))  notitle w lines  ls 27, \
     "collected_$intv.table" using 1:(f(\$8/10))  title "maximum 7 tries" lc rgb "green" pt 13 lw 1, \
     "collected_$intv.table" using 1:(f(\$8/10))  notitle w lines  ls 27, \
     "collected_$intv.table" using 1:(f(\$9/10))  title "maximum 8 tries" lc rgb "black" pt 17 lw 1, \
     "collected_$intv.table" using 1:(f(\$9/10))  notitle w lines  ls 27, \
     "collected_$intv.table" using 1:(f(\$10/10)) title "maximum 9 tries" lc rgb "red" pt 19 lw 1, \
     "collected_$intv.table" using 1:(f(\$10/10)) notitle w lines  ls 27, \
     "collected_$intv.table" using 1:(f(\$11/10)) title "maximum 10 tries" lc rgb "blue" pt 12 lw 1, \
     "collected_$intv.table" using 1:(f(\$11/10)) notitle w lines  ls 27, \
     g(x)/10 title "calculated probability for 1 try"

gnuplot screenshot

What I want is: x = 0.01 should be nearer to x = 0 and x = 0.05 should be nearer to x = 0.01 and so on. But The distance between increasing x should decrease as x grows (that's why I use a logarithmic scale)

The strange thing is that when I use

set logscale x 2

or

set logscale x 100

it looks exactly the same!

How can I get the desired result?

Upvotes: 1

Views: 373

Answers (1)

sweber
sweber

Reputation: 2976

It is no wonder that it always looks the same. Switching to a log scale means applying a log function (to the base of 10 by default) to the original data:

x_toPlot = log_10( x_data )

If you choose an arbitrary base, logarithmic laws are used to do the conversion with standard bases:

x_toPlot = log_b( x_data ) =  log_10( x_data ) / log_10( b )

The only difference is the factor 1 / log_10( b ), so your data is just stretched without changing the relative position of the points with respect to each other. As gnuplot applies another factor to fit the data into the graph, you won't notice any visible difference.

The only thing affected by specifying an arbitrary base for a log scale are the tick marks, which change from 1, 10, 100, ..., 10n to 1, b, b², ...bn

You can only try another axis conversion. Do you have an idea on how the x-position of... e.g. y=75% depends on the number of tries? The reverse function would be a good candidate for your own conversion. How to implement that, I already wrote, well, you!

As said there, it is very difficult to interpret non-linear axes correctly, don't use it too much

Finally, your plot doesn't look that bad. I would fit the probability function (blue) to each of the datasets and plot its x-position versus the number of tries in a second plot.

Upvotes: 4

Related Questions