我有如下数据:
label1: <set of increasing numbers 1..500>
label2: <set of increasing numbers 1..500>
等
我想用这张照片拍一张照片:
label1 ... ............... .... . .
label2 ................ ..............
etc
1 2 3 ... 500
可以使用gnuplot以相对简单的方式完成此操作吗? 我可以很容易地将数据转换成任何形式,我只是不知道将什么馈入gnuplot。
答案 0 :(得分:1)
也许,我们这里需要一些直观的示例来找出您真正想要的。
后面应该是复制粘贴代码。
如果您要从文件中读取数据,请用您的文件名替换$Data
命令中的plot
,例如'Data.dat'
。这会更接近您想要的吗?
reset session
$Data <<EOD
label1 label2 label3
1 3 6
2 6 9
20 23 31
21 26 34
22 25 29
56 50 44
57 58 55
58 60 70
59 65 85
EOD
set colorsequence classic
set key top left
set yrange [0.5:3.5]
plot for [i=1:*] $Data u i:(i):ytic(columnhead(i)) with points pointtype 7 pointsize 2 notitle
应导致:
添加: 以下代码是一个丑陋的解决方法,可以使用gnuplot基本上将数据转置。除了我通过删除和添加一些点使行的长度不同之外,绘图结果应该与上面的基本相同。
### plotting rows with different length
reset session
$DataInRows <<EOD
label1 1 2 20 21 22 56 57 58 59
label2 3 6 23 26 25 50 58
label3 6 9 31 34 29 44 55 70 88 90
EOD
stats $DataInRows u 0 nooutput # get the number of rows
RowCount = STATS_records
array Rows[RowCount] # define an array
# put rows as string into the array
set table $Dummy
MaxColCount = 0
set datafile separator "\n" # full lines
# get the lines into array and at the same time determine the maximum number of columns
plot $DataInRows u (Rows[$0+1]=stringcolumn(1), \
MaxColCount = words(Rows[$0+1]) > MaxColCount ? words(Rows[$0+1]) : MaxColCount) \
with table
set datafile separator whitespace # set back to default
unset table
print MaxColCount
set print $Data # print into dataset
do for [j=1:MaxColCount] {
tmp = ''
do for [i=1:RowCount] {
tmp = i > 1 ? tmp."\t".word(Rows[i],j) : word(Rows[i],j)
}
print tmp
}
set print
set colorsequence classic
set yrange [0.5:3.5]
plot for[i=1:RowCount] $Data u i:(i):ytic(columnhead(i)) w p pt 7 ps 2 notitle
### end of code