Gnuplot: find x value for given y

前端 未结 1 1235
醉话见心
醉话见心 2021-01-21 18:17

I want to do exactly this: https://tex.stackexchange.com/questions/165360/pgfplots-and-gnuplot-how-to-add-asymptote-a-xtick-that-isnt-a-number-and-can/165366#165366?newreg=53a34

相关标签:
1条回答
  • 2021-01-21 18:48

    The procedure is the same as described in the link you give: Find the inverse of the function and add the result.

    The inverse of your function is (f(x)-b)/m. To display the result, use set arrow, with the graph coordinate system to hit the axes, and first to get the coordinates of the actual intersection.

    To add the results on the axes, use set xtics add and set ytics add.

    An example script (without the fitting part):

    reset
    set xlabel "Distance (kpc)"
    set ylabel "Velocity (km/s)"
    set grid
    
    m = 234; b = 1
    f(x)=m*x+b
    set xrange [0:10]
    set yrange [10:]
    set tics nomirror
    set logscale y
    
    set samples 1000
    y = 2000.0
    
    set arrow from graph 0, first y to first (y-b)/m,y nohead lt 3
    set arrow from first (y-b)/m, y to first (y-b)/m, graph 0 nohead lt 3
    set ytics add (sprintf("%.f", y) y)
    set xtics add (sprintf("%.2f", (y-b)/m) (y-b)/m)
    plot f(x) lw 2 lc rgb"black"
    

    0 讨论(0)
提交回复
热议问题