Gnuplot:找到给定 y 的 x 值

Gnuplot: find x value for given y

我想这样做:https://tex.stackexchange.com/questions/165360/pgfplots-and-gnuplot-how-to-add-asymptote-a-xtick-that-isnt-a-number-and-can/165366#165366?newreg=53a345ba2c3f4f4fbf210af7872b1168 但是在 gnuplot 中(没有乳胶的东西)。 我该怎么做?

这是我的 plt 文件:

reset
set xlabel "Distance [kpc]"
set ylabel "Velocity [km/s]"
unset key
set grid
f(x)=m*x+b
set xrange [0:10]
set yrange [10:]
set xtics
set xtics nomirror
set ytics nomirror
set logscale y
fit f(x) "vd.dat" u 1:2 via m, b
plot f(x) lw 2 lc rgb"black"
set term png
set output "~/uni/J2017+0603/J2017+0603_sim_pm_modified.png"
show output
plot f(x) lw 2 lc rgb"black"

这是输出: plot http://www.ifirn.de/inh/J2017+0603_sim_pm_modified.png

我想知道,例如,哪个距离属于87km/s。 我用 gnuplot 从 87km/s 画一条水平线到图形,然后垂直向下到 x 轴并显示结果。

过程与您给出的link中描述的相同:求函数的反函数并将结果相加。

你的函数的反函数是 (f(x)-b)/m。显示结果,用set arrow,用graph坐标系打坐标轴,first得到实际交点坐标

要在坐标轴上添加结果,请使用 set xtics addset ytics add

一个示例脚本(没有拟合部分):

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"