终端png中的\ Sqrt {x}已增强

时间:2016-04-25 14:12:54

标签: gnuplot

我正在使用Gnuplot,我想在png文件的xlabel中获得根方符号,所以我像这样设置xlabel: 设置xlabel'\ sqrt {4x} / x' 但在.png文件中,我没有找到任何将\ sqrt转换为符号的内容 感谢

2 个答案:

答案 0 :(得分:1)

Gnuplot支持现代版本的unicode。如果您通过支持unicode与它连接的终端,您可以直接输入unicode字符(不同的操作系统将使用不同的方法来执行此操作)。如果你在png终端中使用的字体支持该字符,它将出现在最终的情节中。

在Windows上,这不起作用,因为wgnuplot.exe可执行文件或Windows命令提示符都不允许使用unicode。您可以通过脚本文件提供它(假设文件使用utf-8编码)并使用gnuplot.exe可执行文件运行它。

例如,我们可以创建脚本

set term png
set output "squareroot.png"
plot sqrt(x) t "√x"
set output

然后使用gnuplot scriptfile运行它以生成

Example with square root

再举一个例子,让我们假设我们希望标题是笑脸(unicode character 263A),我们可以使用以下脚本

set term png
set output "squareroot.png"
set title "☺☺☺☺☺☺☺☺☺☺"
plot sqrt(x) t "√x"
set output

产生

enter image description here

我在notepad.exe中创建了此脚本,并确保编码设置为utf-8。要键入squareroot符号,我按照http://www.fileformat.info/info/unicode/char/221a/index.htm的建议按住alt键并键入251。 Windows使得直接键入unicode值变得困难,但是可以使用注册表设置。我使用的方法引用了活动代码页。

如果没有注册表修改,我们就无法在Windows中输入笑脸。但是,一个非常简单的python 3代码行(open("testsq.txt","wb").write("\u263a".encode("utf-8")))将笑脸符号转储到文本文件中,然后我们可以打开它(以utf-8模式)并复制并粘贴到脚本中。

答案 1 :(得分:0)

不使用乳胶端子,似乎无法使用位图端子。 您最接近的是使用enhanced text mode并输入"square root" character

但是,您无法直接或使用utf8编码直接输入Unicode代码点。 相反,检查that table,它似乎可以使用八进制值326生成。

所以演示代码将是:

set terminal pngcairo
set termoption enhanced
set output "aa.png"
set ylabel "{/Symbol=\326}x/x"
plot sqrt(sin(x))/x
相关问题