Reputation: 34517
I have data which looks like this:
label1: <set of increasing numbers 1..500>
label2: <set of increasing numbers 1..500>
etc
I would like to make a picture out of that would look something like:
label1 ... ............... .... . .
label2 ................ ..............
etc
1 2 3 ... 500
Can this be done with gnuplot in some relatively straightforward way? I can transform the data into any form easily, i just don't know what to feed into gnuplot.
Upvotes: 1
Views: 151
Reputation: 25704
maybe, we need some visual example here to find out what you really want.
The follwing should be a copy&paste code.
If you are reading your data from a file, replace $Data
in the plot
command by your filename, e.g. 'Data.dat'
. Does this come closer what you want?
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
which should result in:
Addition: The following code is an ugly workaround to basically transpose the data with gnuplot. The plotting result should be basically the same as above, except I made the rows different in length by removing and adding some points.
### 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
Upvotes: 1