我知道如何在gnuplot中定义没有空格的字符串数组,例如,
titles = "LineA LineB"
如何定义字符串包含空格的字符串数组,例如Line 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:我的gnuplot的版本是:
G N U P L O T
Version 4.6 patchlevel 4 last modified 2013-10-02
Build System: Linux x86_64
答案 0 :(得分:0)
如@Christoph在评论中所述,gnuplot 4.6 是不可能的,但 5.0 支持此操作。
要安装gnuplot 5.0,请从here下载源文件,然后:
#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 Version 5.0.1 Release Notes。
$ 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>