40

I'm trying to plot in gnuplot a log-periodic function: cos((log(abs(t-Tc))*PI/log10(lambda) ) + phi)

But because of the nature of log(x) near to x=0, the plot is getting ugly.

How to plot a log-periodic function in gnuplot so it looks nice?

My plot script looks like this:

phi = 1
TcFormated = 9.67e+8
lambda = 2
PI = 3.1415

g(t) = abs(cos((log(abs(t-TcFormated))*PI/log10(lambda) ) + phi))

set tmargin at screen 0.01
set bmargin at screen 0.99
set lmargin at screen 0.01
set rmargin at screen 0.99

set xrange [8.4e+8:1.04e+9]
set yrange [0:1]
unset xtics
unset ytics
plot g(x) t '' w l

pause -1

log-periodic function

After setting:

set samples 10000

I got a much better looking graph: log-periodic function with set samples 10000

czerasz
  • 13,682
  • 9
  • 53
  • 63
  • 5
    I cannot believe that 100 is default. Even abs(x) is ugly. I opened "make 'set samples 1000' a default" feature request, lets see what will happen - https://sourceforge.net/p/gnuplot/feature-requests/376/ – Bulwersator Dec 18 '13 at 08:27
  • Different rates for different functions: http://stackoverflow.com/questions/19524582/different-number-of-samples-for-different-functions – Ciro Santilli OurBigBook.com Oct 08 '15 at 17:05
  • Cannot believe it was rejected so quickly! @Bulwersator – innisfree Feb 23 '18 at 04:31

1 Answers1

45

If you want to increase the resolution try

set samples <X>

where <X> is an integer. Per default this integer is set to 100. Increase that number to your needs.

Though, the higher the integer is chosen the longer it will take gnuplot to plot the graph.

Woltan
  • 13,723
  • 15
  • 78
  • 104