Reputation: 101
I'm trying to make a very simple graph in matplotlib, and for some reason it produces a graph without a line.
The plotting code:
print(infected_list)
print(generations_list)
plt.plot([generations_list],[infected_list])
plt.ylabel("Infected")
plt.xlabel("Generations")
plt.show()
I've also tried it with:
plt.plot([generations_list],[infected_list],color="red")
The output of the print function, showing the values of infected_list and generations_list:
[1, 2, 3.6, 6.8, 13.2, 26.0, 51.6, 100, 100, 100, 100, 100]
[0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
The resulting graph, with no line:
Any ideas what I'm doing wrong? Thank you!
Upvotes: 0
Views: 137
Reputation: 101
It was a very simple mistake on my part, I was passing a list of a list. All I had to do was change
plt.plot([generations_list],[infected_list])
to
plt.plot(generations_list,infected_list)
Thank you to Mateen Ulhaq for answering it so quickly!
Upvotes: 1