Skip to content

Commit 7ea7316

Browse files
committed
adding legend to chart
1 parent f63c3f9 commit 7ea7316

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

python-first/chart.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@
4545

4646
fig, ax = plt.subplots()
4747

48-
plot = ax.plot(positions, looping_times)
49-
plot = ax.plot(positions, generator_times)
48+
plot = ax.plot(positions, looping_times, label="loop")
49+
plot = ax.plot(positions, generator_times, label="generator")
5050

5151
plt.xlim([0, LIST_SIZE])
5252
plt.xlabel("Position of element to be found")
5353
plt.ylim([0, max(max(looping_times), max(generator_times))])
5454
plt.ylabel(f"Time to complete {TIMEIT_TIMES:,} times")
55+
plt.legend()
5556

5657
plt.show()

0 commit comments

Comments
 (0)