如何在终端的gnuplot标签中使用字符串和变量?

如何在终端的gnuplot标签中使用字符串和变量?,gnuplot,Gnuplot,是否可以在终端的gnuplot标签中使用自定义变量和字符串? 我想要一个标签,上面写着:“t85=15.6”,其中“t85=”是字符串,“15.6”是我在gnuplot脚本中设置的变量 set terminal epslatex set output 'TP_MAG_5s_Decklage1.tex' set xlabel "time / s" set xrange [0:250] set ylabel "T / C" set yrange [0:1800] TP_MAG_5s_Decklage

是否可以在终端的gnuplot标签中使用自定义变量和字符串? 我想要一个标签,上面写着:“t85=15.6”,其中“t85=”是字符串,“15.6”是我在gnuplot脚本中设置的变量

set terminal epslatex
set output 'TP_MAG_5s_Decklage1.tex'
set xlabel "time / s"
set xrange [0:250]
set ylabel "T / C"
set yrange [0:1800]
TP_MAG_5s_Decklage1.dat"
t85_1 = system("awk '$1<800 && $1>500 { count++ } END { print count/100 }' TP_MAG_5s_Decklage1.dat")
t85_2 = system("awk '$2<800 && $2>500 { count++ } END { print count/100 }' TP_MAG_5s_Decklage1.dat")
set label 1 at 150,700 t85_1 
set label 2 at 150,600 t85_2 
plot 'TP_MAG_5s_Decklage1.dat' using ($0/100):1 w l title 'TC 1',\
     'TP_MAG_5s_Decklage1.dat' using ($0/100):2 w l title 'TC 2',\
      800 notitle , 500 notitle
设置终端地址
设置输出“TP_MAG_5s_Decklage1.tex”
设置xlabel“时间/秒”
设置X范围[0:250]
设置标签“T/C”
设置Y范围[0:1800]
TP_MAG_5s_Decklage1.dat“
t85_1=系统(“awk'$1500{count++}END{print count/100}”TP_MAG_5s_Decklage1.dat”)
t85_2=系统(“awk'$2500{count++}END{print count/100}”TP_MAG_5s_Decklage1.dat”)
将标签1设置为150700 t85_1
将标签2设置为150600 t85_2
使用($0/100)绘制“TP_MAG_5s_Decklage1.dat”:1 w l标题“TC 1”\
“TP_MAG_5s_Decklage1.dat”使用($0/100):2 w l标题“TC 2”\
800诺蒂尔,500诺蒂尔

此代码仅将变量的值作为标签提供给我。我无法向此标签添加一些文本。

当您使用
epsletase
终端时,您的gnuplot脚本应生成两个文件:一个带有绘图本身的
.eps
,一个带有所有标签的
.tex
。因此,如果您只打开
.eps
文件e、 您将看不到标签。假设脚本生成
plot.tex
plot.eps
,运行以下命令将生成一个包含所有标签的
myfile.pdf
文件:

#!/bin/bash    

cat << EOF > myfile.tex
\documentclass{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\begin{document}
\input{plot}
\end{document}
EOF

pdflatex  myfile
!/bin/bash
cat myfile.tex
\documentclass{article}
\usepackage{graphicx}
\usepackage{epstopdf}
\开始{document}
\输入{plot}
\结束{document}
EOF
pdflatex myfile

希望这能解决您的问题。另请看。

我的问题的解决方案是这样设置标签:

set label 1 at 150,700 gprintf("$t_{8/5}$ = %.2f s",t85_1) 

这样我就可以使用Latex数学模式并调用变量。

当缺少结束符<代码>$或某些文本应该处于数学模式<代码>$text$而不是时,通常会发生此错误。谢谢,我发现缺少$符号,但我想在标签中使用Latex命令(我更改了示例代码以显示此问题)你需要gprintf来显示变量名,你可以在引号中写$,这样它就会被LaTeX解释。谢谢,解决了。我很高兴它被解决了!