Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 如何在gnuplot中定义字符串(包含空格)数组?_Arrays_Gnuplot - Fatal编程技术网

Arrays 如何在gnuplot中定义字符串(包含空格)数组?

Arrays 如何在gnuplot中定义字符串(包含空格)数组?,arrays,gnuplot,Arrays,Gnuplot,例如,我知道如何在gnuplot中定义没有空格的字符串数组 titles = "LineA LineB" 如何定义字符串中包含空格的字符串数组,例如行a?以下是源代码,但它不起作用 titles = "'Line A' 'Line B'" set style line 1 pt 2 lc rgb 'green' set style line 2 pt 4 lc rgb 'red' plot for [i = 1:words(titles)] file using 2:3 with lp l

例如,我知道如何在gnuplot中定义没有空格的字符串数组

titles = "LineA LineB"
如何定义字符串中包含空格的字符串数组,例如
行a
以下是源代码,但它不起作用

titles = "'Line A' 'Line B'"

set style line 1 pt 2 lc rgb 'green'
set style line 2 pt 4 lc rgb 'red'

plot for [i = 1:words(titles)] file using 2:3 with lp ls i title word(titles, i)
PS:my gnuplot的版本是:

G N U P L O T
Version 4.6 patchlevel 4    last modified 2013-10-02 
Build System: Linux x86_64

正如@Christoph在评论中提到的,gnuplot4.6是不可能的,但是5.0支持此操作

要安装gnuplot 5.0,请从下载源文件,然后:

#decompress it:
tar -xvf gnuplot-5.0.1.tar.gz

#install the dependency libraries for cairo-based terminals, like pdfcairo
sudo apt-get install libcairo2-dev
sudo apt-get install libpango1.0-dev


#build it:
cd gnuplot-5.0.1 
./configure 
make

#test it:
#make check

#install it:
sudo make install

有关更多信息,请参阅


使用gnuplot版本4.6。这是不可能的,在5.0版本中,您显示的变体可以正常工作。如果您这样做,您将只剩下很少的终端。在./configure的输出的最后一页上检查缺少哪些库,并安装相应库的-dev包,例如libgd、cairo、pango、qt等。短时间的谷歌搜索应该会有所帮助。@Karl Ratzsch。你是对的。我已经编辑了我的答案。欲了解更多信息,请参考另一个问题。好的,那是关于开罗的非交互式终端。你怎么知道用户使用的是基于debian的系统?@KarlRatzsch我弄明白后回答了我的问题。啊,没注意到你也问了原来的问题。顺便说一句,debian backports(还有ubuntu,我猜还有其他发行版)也有一个现成的gnuplot 5.0二进制包。使用它而不是自己编译通常会更好,因为这样所有的teminal都可以工作,包括postscript,它的正确安装是出了名的麻烦。此外,根据库版本(qt4/5、wxt2.8/3.0、gtk+2/3…)和基础系统的组合,wxt和qt可能会出现一些问题,这些问题不容易解决。
$ gnuplot

    G N U P L O T
    Version 5.0 patchlevel 1    last modified 2015-06-07 

    Copyright (C) 1986-1993, 1998, 2004, 2007-2015
    Thomas Williams, Colin Kelley and many others

    gnuplot home:     http://www.gnuplot.info
    faq, bugs, etc:   type "help FAQ"
    immediate help:   type "help"  (plot window: hit 'h')

Terminal type set to 'x11'
gnuplot>