gnuplot - 计算线之间的距离

标签 gnuplot distance lines

gnuplot 可以计算两条线或两点之间的距离吗?

我有一个情节,其中绘制了两条(主)线。目前让我们假设第一行总是在第二行之上。有没有办法在给定的 x 值处计算从第 2 行到第 1 行的距离?

这是我的情节的样子以及我要计算的距离的图片:

the solid horizontal line is line 1, the dotted horizontal line is line 2

竖线只是样式,与实际绘图无关,它们的数据存储在test.dattest2.dat .

我的行数据文件如下所示:
第 1 行

0       118.1
2.754   117.77
4.054   117.64
6.131   116.17
7.7     116.04
8.391   115.36
10.535  115.25
11.433  116.03
12.591  116.22
19.519  118.59

第2行
19.4    118.51
15.2    116.56
10.9    115.94
10.35   114.93
9.05    114.92
8.3     115.9
5.9     116.19
4.2     116.62
2.2     117.66
-0.3    118.06

我的绘图代码如下所示:
set term wxt enhanced
cd 'working directory'
unset key

set size 0.9,0.9
set origin 0.1,0.1
set title 'TITLE'

unset border
set label 21 "  rotate by 45" at -3.0,0.0 rotate by 45 point ps 2

set xrange [0:19.519]
set yrange [110:119] 
set xtics nomirror(0, 2.745, 4.054, 6.131, 7.7, 8.391, 10.535, 11.433, 12.591, 19.519) rotate by 90 offset 0,-0.1 right

set ytics "      ", 30000

plot "line1.dat" using ($1):($2):2 with labels offset 1, 1.8 rotate by 90, "line1.dat" using 1:2 with lines lt 1 lw 1 lc rgb '#000000', +112 lt 1 lw 1 lc rgb '#000000' , 'test.dat' with lines lt 1 lw 1 lc rgb '#000000', +110 lt 1 lw 1 lc rgb '#000000', 'line2.dat' with lines lt 0.5 lw 1 lc rgb '#000000', 'test2.dat' with lines lt 0.5 lw 1 lc rgb '#000000' 

最佳答案

您可以手动测量距离。将鼠标移动到第一个点并输入“r”。然后当您四处移动鼠标时,会显示 x 和 y 偏移量、距离和角度。键入“5”以绘制线段并在度数和切线显示之间切换。预先放大可提高准确性。

顺便说一句,在绘图窗口中键入“h”将显示控制台的键绑定(bind)列表。

关于gnuplot - 计算线之间的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17717287/

相关文章:

gnuplot - 如何通过我的 gnuplot 脚本检查终端是否可用?

gnuplot - gnuplot 标签中的逗号

gnuplot:日期和时间在 x 轴的单独列中,对输入文件进行排序

elasticsearch - Elasticsearch查询文档,其中两个位置具有相对距离

distance - 使用哪种数据结构来存储二进制字符串并使用汉明距离进行查询

ios - 计算与网格中目标距离的最佳方法

c++ - DirectX 11 - 子弹调试抽奖

linux - 如何在ggplot中绘制两个尺度的一些数据

c# - 在 C# 中开始新行时,如何在 TextBox 中创建新行?

java - 在 BufferedImage 中绘制多条线