I have been trying to plot values stored in lists as dict values but I have gotten stuck. Heres an example of the structure of the dictionary and my code to iterate over die keys and values:
import matplotlib.pyplot as plt
mydict = {
"A":
[1.0, 0.75, 0.0, 0.25, 0.0, 0.5, 0.0, 0.5, 0.0, 0.5, 0.5],
"B":
[1.0, 0.0, 0.0, 0.0, 0.5, 0.6666666666666666, 0.0],
"C":
[0.6666666666666666, 0.3333333333333333, 0.75, 0.25, 0.0, -1, 0.5, 0.75, 0.0, 0.0, 0.0],
"D":
[0.0, 0.0, 0.0, 0.2]}
for k, v in mydict.iteritems():
plt.title('Some data for unit: ' + k)
plt.xlabel('Number of data points')
plt.ylabel('Some unit')
plt.figure(k)
xs = range(0, len(v))
ys = v
plt.plot(xs, ys, '-.')
plt.show
Im a relative beginner and I probably missed something basic and essential, but the following always happens: The first plot comes out empty with the title for unit A and the last one has no title or labels. So Im guessing it mocks up an empty plot for Unit A, plots data for Unit A in the second plot, Unit B in plot three and so forth until the fifth plot, which I did not expect to be there, considering my dict only has four key value pairs.
What am I missing here? Ive tried for hours and just cant come up with a solution.
Many thanks!