在gnuplot标题中显示下划线而不是下标 [英] Display underscore rather than subscript in gnuplot titles

查看:267
本文介绍了在gnuplot标题中显示下划线而不是下标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简短问题: 如何在gnuplot中的标题中显示_(下划线)字符,该标题是从gnuplot中的变量名称分配的?

Short question: How do I display the _ (underscore) character in a title in gnuplot that is assigned from a variable name in gnuplot?

详细信息: 我有类似以下代码的内容:

Details: I have something like the following code:

items = "foo_abc foo_bcd bar_def"
do for [item in items] {
  set title item
  set output item.eps
  plot item."-input.txt" using 1:2 title item with linespoints
}

这与gnuplot正常工作,除了标题从foo_abc更改为foo a bc.我不知道是否要使用转义字符,因为我不想在文件名中使用该字符.我用单引号和双引号尝试了几种不同的选择,但是我还没有找到我需要的东西.

This works fine with gnuplot except that the title get changed from foo_abc to fooabc. I don't know if I want to use an escape character because I don't want that to be in the file name. I've tried a couple of different options with single vs. double quotes but I haven't found what I need yet.

推荐答案

如果您使用增强的eps终端,这就是您首先需要转义下划线的原因.今天有一个另一个相关问题,该问题有所解释.设置终端时,请尝试:

If you are using the enhanced eps terminal, that is the reason you need to escape the underscore in the first place. There was another related question today which explains the issue a bit. When you set the terminal, try:

set terminal postscript noenhanced <whatever else here...>

这对我有用(Arch linux,gnuplot 4.7.0).如果增强型终端是必不可少的,下面是我发现的部分解决方案.假定下划线始终出现在字符串的相同位置.

That works for me (Arch linux, gnuplot 4.7.0). If the enhanced terminal is essential, below is a partial solution I found. The assumption is that the underscore always appears in the same place in the string.

set terminal postscript enhanced
items = 'foo\_abc foo\_bcd bar\_def'
do for [item in items] {
  set output item[1:3].item[5:*].'.eps'
  set title item
  plot sin(x)
}

这样,您可以转义下划线并且文件名中不会出现\.注意对"items"字符串使用单引号;有关详细信息,请参见前面链接的问题.

This way you can escape the underscore and not have the \ appear in the filename. Note the use of single quotes for the 'items' string; see the previously linked question for details.

这篇关于在gnuplot标题中显示下划线而不是下标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆