我如何在 gnuplot 中定义一个字符串(包含 space)数组?
How can I define a string (contain space) array in gnuplot?
我知道如何在 gnuplot 中定义一个没有 space 的字符串数组,例如,
titles = "LineA LineB"
如何定义一个字符串数组,其中字符串包含一个space,例如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
@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>
我知道如何在 gnuplot 中定义一个没有 space 的字符串数组,例如,
titles = "LineA LineB"
如何定义一个字符串数组,其中字符串包含一个space,例如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
@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>