gnuplot 4.6引入了do命令。我怎样才能使用这个来循环文件中的颜色数组?什么是正确的语法?
colors = "red green #0000FF"
files = "file1 file2 file3"
do for [i=1:3] {
plot files(i).".dat" lc colors(i)
}
发布于 2018-01-12 14:04:05
以下两个解决方案都将一个图中的所有数据绘制在一起,但在迭代中会有所不同。
第一种解决方案word
是在绘图时直接从字符串中提取单词。
colors = "red green #0000FF"
files = "file1 file2 file3"
plot for [i=1:words(files)] word(files, i).'.dat' lc rgb word(colors, i)
第二个解决方案更改linetype
,然后直接遍历单词列表,而不是使用索引。
colors = "red green #0000FF"
files = "file1 file2 file3"
set for [i=1:words(colors)] linetype i lc rgb word(colors, i)
plot for [file in files] file.'.dat'
https://stackoverflow.com/questions/-100007138
复制相似问题