Gnuplot:找到给定y的x值 [英] Gnuplot: find x value for given y
问题描述
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=53a345ba2c3f4f4fbf210af7872b1168 but in gnuplot (without the latex stuff). How can I do that?
这是我的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"
这是输出: 绘制http://www.ifirn.de/inh/J2017+0603_sim_pm_modified.png
例如,我想知道哪个距离属于87km/s. 然后我用gnuplot在87km/s的水平线上绘制图形,然后垂直向下到x轴并显示结果.
And I want to know, for example, which distance belongs to 87km/s. And I wnat gnuplot to draw a horizontal line from 87km/s to graph, then vertical down to the x-axis and display the result.
推荐答案
该过程与您提供的链接中所述的过程相同:查找该函数的逆并添加结果.
The procedure is the same as described in the link you give: Find the inverse of the function and add the result.
您的函数的倒数是(f(x)-b)/m
.要显示结果,请使用set arrow
,使graph
坐标系命中轴,并使用first
获取实际交点的坐标.
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.
要在轴上添加结果,请使用set xtics add
和set ytics add
.
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"
这篇关于Gnuplot:找到给定y的x值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!