Gnuplot - how to scale xyrange to not take into ac

2019-02-26 01:16发布

问题:

I have a data file _FullWV.dat and I want Gnuplot to automatically scale xyrange if outside the wanted region z < 10^(-8), is there any way to make it?

Graph is here.

The used script is below:

reset
set terminal pngcairo size 800,800
set output '3d-polar.png'
set lmargin at screen 0.05
set rmargin at screen 0.85
set bmargin at screen 0.1
set tmargin at screen 0.9

set pm3d map
unset key
set multiplot

stats '_FullWV.dat' using 3
max(a,b) = (a>b) ? a : b

Z_MAX = max(-STATS_min, STATS_max)

set parametric
set grid xtics ytics

set angles degree
set autoscale xfix
set autoscale yfix
#set zrange [-Z_MAX : Z_MAX]
set cbrange [-Z_MAX : Z_MAX]

set palette model RGB defined ( 0"black", 1"white", 2"grey")
splot '_FullWV.dat' u ($2*cos($1)):($2*sin($1)):3
unset multiplot

回答1:

Code

set size ratio -1
splot '_FullWV.dat' u (abs($3)<1e-5 ? NaN : $2*cos($1)):($2*sin($1)):3

1e-8 was too small, it cut almost nothing from the original range.

Explanation

abs($3)<1e-5 ? NaN : $2*cos($1)

If z (3rd column) is between -1e-5 and 1e-5, leave x undefined (Not a Number). If x is undefined, no point will be displayed, even if y and z are defined.

If z is outside this range, define x as $2*cos($1).

Note that for pm3d, at least 2 consecutive values are needed for a point to be displayed. It means that 1 lone value will be take into account by autoscale, but will not be displayed.

set size ratio -1

means that one unit on the x scale will be as big as one unit on the y scale : a circle might be displayed as an ellipse otherwise.



标签: gnuplot