Reputation: 378
I have data like:
A 1
B 2
C 1
D 3
A 4
B 3
C 2
D 1
Where the first column will repeat a small number of key
names. But it's a variable number and the values can change from run to run.
Is there a plot
definition i can use that'll use the first column as they key
, plot the second column as y
and plot x
from the data point number per key
?
Upvotes: 1
Views: 295
Reputation: 14023
AFAIK this is not possible. Gnuplot can do some sort of arithmetic but not of this kind. Either you tweak the program that exports this kind of data format to something gnuplot can handle or write a little script that does the same trick for you.
If I understood you correctly this python script should do convert the data into something gnuplot can handle:
#data = <read your data file>
Content = data.split("\n")
Dict = dict()
for l in Content:
Line = l.split(" ")
if not Line[0] in Dict:
Dict[Line[0]] = int(Line[1])
else:
Dict[Line[0]] += int(Line[1])
file = open("Output.data", "w")
for (key, value) in Dict.items():
file.write(key + " " + str(value) + "\n")
file.close()
Upvotes: 1