This one is actually a doosie and I can't make it happen without some *nix shell magic.
First, we want to get the x tic labels and y tic labels:
XTICS="`awk 'BEGIN{getline}{printf "%s ",$1}' test.dat`"
YTICS="`head -1 test.dat`"
At this point, XTICS is the string "F G H I J" and YTICS is the string "A B C D E".
Now, we want to set the xtics by iteration:
set for [i=1:words(XTICS)] xtics ( word(XTICS,i) i-1 )
set for [i=1:words(YTICS)] ytics ( word(YTICS,i) i-1 )
We've used 2 gnuplot builtin functions (word
and words
). words(string)
counts how many words there are in the given string (a word is a character sequence separated by spaces). word(string,n)
returns the n'th word in the string.
Now, we can plot your datafile ... The only problem is that matrix
wants to use all rows and columns in your datafile. You might be able to cut down the rows/columns actually read by using the every
keyword, but I don't know how to do that on matrix files -- and I think it's probably easier to just keep on relying on shell utilities (awk
and sed
)
plot "<awk '{$1=""}1' test.dat | sed '1 d'" matrix w image
#######^ replace the first field with nothing
################################## ^ delete first line
And now your plot (hopefully) looks the way you want it to.
Also note that since we have used iteration, this script will only work in gnuplot 4.3 or higher -- Since the current stable is 4.6, hopefully that's Ok.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…