我正在尝试生成一个 gnuplot,它使用来自两个不同数据文件的数据来绘制同一条绘图线,如下所示:
plot 'datafile1.dat' using 1:($2/('datafile2.dat' using 2)
Run Code Online (Sandbox Code Playgroud)
即 x 轴:第 1 列datafile1.dat;y 轴:( 的第 2 列datafile1.dat)除以( 的第 2 列datafile2.dat)
上面的语法显然是不正确的,但是有没有办法使用 gnuplot 来实现这一点?
输入数据集示例如下:(两个数据文件都有相似的数据集)
nSp Kf
10 523276.8
50 6915841.1
100 24736818.3
500 622677171.35
1000 2892599744
...
Run Code Online (Sandbox Code Playgroud)
我在网上读到的其他解决方案需要在使用绘图之前连接datafile1.dat和。datafile2.dat实际的数据文件有更多用于其他图的列,因此我希望避免这种连接。如果有人有一个将两个文件分开的替代解决方案,我将非常感激。
谢谢你!
我想使用基于非均匀网格的 gnuplot 创建热图,这意味着我的 x 轴箱的宽度不完全相同,而且我不知道如何做到这一点,因为当我用 for 绘制数据时例如“使用图像”我得到统一大小的框,它们根本不对应于我的坐标(因为“图像”将数据视为我猜的矩阵)。所以我想找到一种方法来获得非均匀框,这些框也位于笛卡尔平面上的正确位置。
我的数据看起来像这样:
1 1 0.2
1 2 0.8
1 3 0.1
1 4 0.2
2 1 0.7
2 2 0.2
2 3 0.3
2 4 0.1
5 1 0.2
5 2 0.4
5 3 0.1
5 4 0.9
7 1 0.3
7 2 0.2
7 3 0.9
7 4 0.6
Run Code Online (Sandbox Code Playgroud)
如果我在 Gnuplot 上运行这个命令
set xrange [1:10]
p 'mydata.dat' with image
Run Code Online (Sandbox Code Playgroud)
我得到一张包含 16 个具有相同宽度和高度的盒子的图像(显然我在 Stackoverflow 上没有足够的“声誉”来发布图像,否则我会的),但理想情况下我希望这些盒子具有不同的宽度并且是在飞机上正确的位置。例如,第一个框的范围应为 1 到 2,第二个框的范围应为 2 到 5,第三个框的范围应为 5 到 7,最后一个框的范围应为 …
我想知道一个值的字符数。
但strlen()仅适用于字符串,不适用于值。( strlen(value("zon")) 不起作用)
示例:zon = 12000,len 值为 5。
这可以用 gnuplot 实现吗?
GN 在绘制数据时生成变量 STATS_max_y。
我想在标签中使用它,例如:
set label 4 "The highest value is: STATS_max_y"
Run Code Online (Sandbox Code Playgroud)
但我不知道如何连接 GN 变量和标签文本。
我试过:
"The highest value is: . STATS_max_y"
Run Code Online (Sandbox Code Playgroud)
我收到内部错误:STRING 运算符应用于非 STRING 类型
我对 gnuplot 还很陌生,所以我很感谢每一个建议。
现在,我正在尝试使用 logscale 命令绘制一些数据。但我不知道为什么当我使用对数刻度时所有 xtics 都会消失。这是我使用的脚本:
#creates a plot of all the four different loops with a logscale. Fits the functions as well and saves the fitting data
#in a file named fitting.dat
set size 1,1
# set logscale
set logscale y 10
set logscale x 10
#set xlabel and y label
set xlabel "Dimension of Matrix"
set ylabel "time [s]"
#scale plot
set xrange [450:850]
set yrange[0.01:5]
#nothing displayed from fitting
set fit quiet
#position of legend …Run Code Online (Sandbox Code Playgroud) 要Gnuplot通过指定参数直接使用(在 Linux Ubuntu 16.04 上)命令而不使用提示符,我输入以下示例:
gnuplot -e "filename='DataFile.txt'" SettingsFile
Run Code Online (Sandbox Code Playgroud)
哪里SettingsFile看起来像这样:
plot filename with lines
set title "Total Packets consumption"
set xlabel "Time"
set ylabel "Packets"
set datafile separator ","
pause -1
Run Code Online (Sandbox Code Playgroud)
看起来DataFile.txt像这样:
数据包、时间(以秒为单位):
13392,120
24607,240
23867,360
21764,480
20727,600
20004,720
19719,840
19758,960
19728,1080
20168,1200
19737,1320
19729,1440
20135,1560
20006,1680
21301,1800
19923,1920
20002,2040
19761,2160
20918,2280
22756,2400
22820,2520
23370,2640
22987,2760
22956,2880
24427,3000
23527,3120
24009,3240
23832,3360
23464,3480
23652,3600
11212,3654
Run Code Online (Sandbox Code Playgroud)
第一个问题:
有没有办法将其设置为SettingsFilepng OutputFile ?因此我可以将其作为 Gnuplot 命令的参数输入,就像我对数据文件所做的那样。(我想这样使用它,因为我想从外部代码调用它)
我想实现这样的目标:
gnuplot …Run Code Online (Sandbox Code Playgroud) 我有以下脚本,可以在 gnuplot 中正常运行(不幸的是我有一个旧版本,现在我对此无能为力,它是 4.0)。
set xlabel "y"
set ylabel "rw[j]"
set title "P-D diagram"
set zeroaxis
set xzeroaxis
plot [0.5:1] \
-5.71429*x title "L[-5]" linetype 1, \
-4.28571*x title "U[-5]" linetype 3, \
-4.71429*x title "L[-4]" linetype 1, \
-3.28571*x title "U[-4]" linetype 3, \
-3.71429*x title "L[-3]" linetype 1, \
-2.28571*x title "U[-3]" linetype 3, \
-2.71429*x title "L[-2]" linetype 1, \
-1.28571*x title "U[-2]" linetype 3, \
-1.71429*x title "L[-1]" linetype 1, \
-0.285714*x title "U[-1]" linetype 3, …Run Code Online (Sandbox Code Playgroud) 我正在 gnuplot 中寻找一个调色板,用于从非常浅的红色到深红色的红色。我在这里找到了一个黑色脚本http://gnuplot.sourceforge.net/demo_5.3/pm3dcolors.16.gnu
我尝试set palette functions red, red, red在上面的脚本中进行更改,但它不起作用。
我正在尝试使用以下方法创建透明颜色的自定义调色板gnuplot:
a=127
rgb(i,a)=int(255*256**(i%3)+(i/3)*96*256**((i+1)%3)+a*256**3)
Run Code Online (Sandbox Code Playgroud)
然后我确实获得了所需的颜色:
plot x w l lc rgb rgb(0,a) lw 32, x+1 w l lc rgb rgb(1,a) lw 32
Run Code Online (Sandbox Code Playgroud)
问题,如果a等于或大于 128,则int返回一个负数,该负数不被识别为颜色。有没有办法在 gnuplot 中获得一个无符号整数?或者任何其他方式将数字理解为超出 #80000000 的十六进制?
这是 x^(1/3) 的正确图形:
但是,当尝试x**(1./3)在 gnuplot 上绘图时,这就是我得到的:
我怎样才能解决这个问题?
此外,这不是 gnuplot 第一次不在其他函数中绘制零附近的值(当然,当它应该这样做时:我不是在谈论渐近线等)。我能做什么?