For the Pygal line graph, we can largely follow the same pattern as our Matplotlib example, where we create lists of values by reading the file. We no longer need to convert the x-axis value into an internal float, as we did for Matplotlib; however, we do need to convert the numbers in each of the values we would have received in the float:
#!/usr/bin/env python3 import pygal x_time = [] out_octets = [] out_packets = [] in_octets = [] in_packets = [] with open('results.txt', 'r') as f: for line in f.readlines(): line = eval(line) x_time.append(line['Time']) out_packets.append(float(line['Gig0-0_Out_uPackets'])) out_octets.append(float(line['Gig0-0_Out_Octet'])) in_packets.append(float(line['Gig0-0_In_uPackets']))