我正在使用gnuplot尝试绘制几条线,但每条线都有不同的x范围.我正在运行以下脚本:
# gnuplot script for 'omarConf2EvONLY-vs-everyone-gta-lag-lpas-omarConf1-random-tag-tpas.dat'
plot "omarConf2EvONLY-vs-everyone-gta-lag-lpas-omarConf1-random-tag-tpas.dat" using 1:2 with lines title '1'
replot "omarConf2EvONLY-vs-everyone-gta-lag-lpas-omarConf1-random-tag-tpas.dat" using 1:3 with lines title '2'
replot "omarConf2EvONLY-vs-everyone-gta-lag-lpas-omarConf1-random-tag-tpas.dat" using 1:4 with lines title '3'
replot "omarConf2EvONLY-vs-everyone-gta-lag-lpas-omarConf1-random-tag-tpas.dat" using 1:5 with lines title '4'
replot "omarConf2EvONLY-vs-everyone-gta-lag-lpas-omarConf1-random-tag-tpas.dat" using 1:6 with lines title '5'
replot "omarConf2EvONLY-vs-everyone-gta-lag-lpas-omarConf1-random-tag-tpas.dat" using 1:7 with lines title '6'
replot "omarConf2EvONLY-vs-everyone-gta-lag-lpas-omarConf1-random-tag-tpas.dat" using 1:8 with lines title '7'
set terminal png size 800,600
set output "omar_vs_everyone-EVONLY.png"
replot
Run Code Online (Sandbox Code Playgroud)
.dat文件只是一个包含以下列的文件:
1 0.5 0.5 0.1
2 0.6 1.3 0.8 …Run Code Online (Sandbox Code Playgroud) 我怎么能在Gnuplot中制作一个如下所示的情节:http://www.fftw.org/accuracy/G4-1.06GHz-gcc3.4/,即有一个明确的x轴?我有这样的数据集:
2 1066.7
4 3122.9
8 4715.2
16 5538.5
32 5757.3
64 5891.4
128 5398.3
256 5280.2
512 5178.4
1024 4048.6
2048 4383
4096 3794.4
Run Code Online (Sandbox Code Playgroud)
每次我绘制时,x轴都是线性刻度,所以我的所有值都是相对于y轴聚集的.我希望每个x值的间距相等,就像在链接图中一样.谢谢.
我想使用here文档在我的bash脚本中存储gnuplot的配置文件,但我需要能够在保持回车符的同时替换bash变量.
以下是我正在使用的摘录:
read -r -d '' GNUPLOT_CONF << 'EOF'
set terminal pngcairo enhanced font 'Verdana, 10'
set title "This is a test"
set xrange [$SMALLEST:$LARGEST]
EOF
Run Code Online (Sandbox Code Playgroud)
如果我
echo $GNUPLOT_CONF
Run Code Online (Sandbox Code Playgroud)
然后变量被正确替换但是所有的回车都被剥离了(因此gnuplot无法执行它)如果我
echo "$GNUPLOT_CONF"
Run Code Online (Sandbox Code Playgroud)
然后格式化是正确的但变量没有被替换(并且gnuplot失败)
gnuplot命令设置为变量,但是所有特殊字符(如引号)都需要进行转义.有没有一个快乐的媒体使用这里的文档,使代码更容易阅读.
我想将这两个图组合在一起,我只想使用一个密钥.如果我设置一个,notitle我可以只使用键获得它们,但图形的形状将会改变.
set term postscript eps
set output "temp.eps"
set multiplot layout 1,2
set xtics ("32" 0, "128" 2, "512" 4, "2048" 6, "8192" 8)
#set grid ytics
set xrange [0:8]
set yrange [0:100]
p "8" u ($0):($6) w lp ps 0.75 notitle, "10" u ($0):($6) w lp lc rgb "#228B22" ps 0.75 notitle, "12" u ($0):($6)w lp lc rgb "black" ps 0.75 notitle , "14" u ($0):($6)w lp lc rgb "blue" ps 0.75 notitle, "16" u ($0):($6) w …Run Code Online (Sandbox Code Playgroud) 假设我的 gnuplot (4.6.2) 版本有以下最小工作示例。
set terminal epslatex size 6cm, 4cm font "" 8 standalone
set output "test.tex"
set xrange [0:10]
set yrange [0:10]
set label "$\\alpha=1\,b=0.1$" at 2,8
plot x
Run Code Online (Sandbox Code Playgroud)
这给了我以下输出:

我现在想要的是将我的参数 alpha 和 b 放在彼此下方,在等号处最佳对齐。
我试过类似的东西
set label "\\begin{eqnarray}\\alpha=1 \\\\ b=0.1\\end{eqnarray}" at 2,8
Run Code Online (Sandbox Code Playgroud)
这不会在 gnuplot 中给我错误,但是在编译时它失败了,错误类似于
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.153 \gplbacktext
Run Code Online (Sandbox Code Playgroud)
这并没有真正帮助我进一步。
关于如何解决这个问题的任何建议?
如何使用来自文件的数据绘制多边形?例如,如果我有一个包含每个数据点的四点多边形边缘坐标的文件,我将如何处理?
例如,包含的数据文件
0 0 0 1 1 1 1 0
2 2 2 3 3 3 3 2
Run Code Online (Sandbox Code Playgroud)
应该在位置(0.5,0.5)和(2.5,2.5)绘制两个二次矩形机智中心.
我的代码是
int gnuplot() {
FILE *gnu;
gnu = _popen(" gnuplot ", "r");
fprintf(gnu, "plot \'C:/Users/user/Documents/gnuplot/cpp/FFT/file.dat\' with linespoints \n ");
fflush(gnu); // I'm not sure how or if this will help, I thought it was related
_pclose(gnu);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
目前我只能打开枪管图窗口的CMD窗口,但不能输入绘图命令或退出它.
告诉我PLZ您如何在gnuplot脚本中
1)解析字符串并从中提取数字和字母/字符串?
2)是否可以使用关联数组以免使用多重IF?
files = system(sprintf("dir /b \"%s*.csv\"", inputPath))
do for [name in files]{
# MY TROUBLES IS HERE
[value, typeID] = parse(name, "*[%d%s]*"); # pseudocode
typesList = {"h": 3600, "m": 60, "s": 1};
scale = value * typesList[typeID];
# MY TROUBLES IS ABOVE
myfunc(y) = y * scale
outputName = substr(name, 0, strlen(name) - strlen(".csv"))
inputFullPath = inputPath.name
outputFullPath = outputPath.outputName.outputExt
plot inputFullPath using 1:(myfunc($2)) with lines ls 1 notitle
}
Run Code Online (Sandbox Code Playgroud)
就我而言,我需要从形式的文件名获得的秒数...[d=17s]...,...[d=2m]...,...[d=15h]...等
在更复杂的情况下:( …