I have the output of a code library which generates energies of "bands" in materials. The data is organised with the lefthand column representing an index and the second as its energy. When I plot it in GNUplot I get this:
The data is organised in the text file as follows:
0 -3.2101962802476773
0 -3.2101962802476773
0 -3.2101962802476773
0 -2.8612484511071283
0 -2.8612484511071212
0 -2.855472070340414
0 -2.855472070340414
0 -2.8473558653791424
1 -3.2098593700677056
1 -3.2098593700677056
1 -2.871177955425835
1 -2.871177955425834
1 -2.8651192493631106
1 -2.865119249363109
1 -2.846669223652509
1 -2.846669223652504
2 -3.209297896654713
2 -3.209297896654713
2 -2.8811028573856685
2 -2.881102857385668
2 -2.8750382428650094
2 -2.875038242865009
2 -2.8460674384836837
2 -2.846067438483675
Where I can (somewhat) see the structure clearly, though the colours make it difficult. What I'd like to do using python & matplotlib is match up the first row of data to the first instance where the value of the left column has changed (so map the first (x,y) pair to the corresponding row where x is now 1), and the same for second, third, fourth etc. Then plot these collections of x and y onto the same graph. Is there a good programmatic way to do this? Would there then also be a good way of ensuring each line (there will be 100) is a different colour/distinguishable from one another?
I thought of doing a loop that packs the first of every value tuple into a key-value pair in a dict and then plot all these dicts on one graph, but not entirely sure on the syntax for this.
Thank you so much!
Edit
Add code given by OP in comment:
with open('BANDS.OUT', 'r') as f:
lines = f.readlines()
x = [float(line.split()[0]) for line in lines]
y = [float(line.split()[1]) for line in lines]