gnuplot: max and min values in a range

后端 未结 3 1253
傲寒
傲寒 2020-12-05 08:10

I\'m plotting some data with a different X range and I would like to change yrange according to the maximum and minimum value of the data in the current X range. When I use

3条回答
  •  自闭症患者
    2020-12-05 08:34

    Setting the yrange to GPVAL_DATA_Y_MIN:GPVAL_DATA_Y_MAX has the disadvantage of not using gnuplots autoscaling functionality which extends the ranges to the next tic.

    In automatic plotting I therefore prefer the following

    f(x)=sin(x)>0.5? 1:-1 #example function
    
    set ytics 0.2
    plot  1.01*f(x) # dummy plot to set GPVAL_*
    set yrange [GPVAL_Y_MIN:GPVAL_Y_MAX]
    
    plot f(x) # actual plot
    

    This also works for data plots of course:

    plot 'data.csv' u 1:(1.01*$2)
    set yrange [GPVAL_Y_MIN:GPVAL_Y_MAX]
    plot 'data.csv' u 1:2
    

提交回复
热议问题