# This example shows how in gnuplot version 5 a nonlinear axis definition
# can be used to set up log-scale axes.  This mechanism replaces a special-case
# logscale implementation provided by previous versions of gnuplot.
# The pair of commands
#	set nonlinear x via log10(x) inverse 10**x
#	set xtics log
# is equivalent to the pre-v5 command
#	set logscale x
# The "set logscale" command is still accepted as a shortcut.
#
# This plot is the same as plot #2 in electrom.dem showing log-scaled axes.
#
set title "Log-scaled axes defined using 'set log'"
set label 1 "This version of the plot uses\nset logscale x\nset logscale y" at graph 0.5, 0.85, 0 center norotate back nopoint

set dummy jw, y
set grid xtics ytics
set key inside center bottom vertical Right noreverse enhanced autotitle box 
set samples 160, 160
set style data lines
set xtics border out scale 1,0.5 nomirror
set ytics border out scale 1,0.5 nomirror
set ytics  norangelimit 0.1 textcolor rgb "dark-violet" 
set y2tics border out scale 1,0.5 nomirror
set y2tics  norangelimit autofreq  textcolor rgb "#56b4e9" 
set xlabel "jw (radians)" 
set ylabel "magnitude of A(jw)" 
set y2label "Phase of A(jw) (degrees)" 
#
set xrange [ 1.1 : 90000.0 ] noextend
set yrange [ 0.1 : 1.0 ]
#
set log x
set log y
set ytics nolog
#
A(jw) = ({0,1}*jw/({0,1}*jw+p1)) * (1/(1+{0,1}*jw/p2))
p1 = 10
p2 = 10000
#
plot abs(A(jw)) lt 1, 180/pi*arg(A(jw)) axes x1y2 lt 3

pause -1 "<cr> to continue"

set title "Log-scaled axes defined using 'set nonlinear'"
set label 1 "The same plot except that 'set logscale' is replaced by\nset nonlinear x via log10(x) inverse 10**x\nset nonlinear y via log10(y) inverse 10**y"

set nonlinear x via log10(x) inverse 10**x 
set nonlinear y via log10(y) inverse 10**y 
set xtics log
set ytics nolog

replot

pause -1 "<cr> to continue"

reset
