This is very simple to do:
import matplotlib.pyplot as plt
plt.plot(<X AXIS VALUES HERE>, <Y AXIS VALUES HERE>, 'line type', label='label here')
plt.plot(<X AXIS VALUES HERE>, <Y AXIS VALUES HERE>, 'line type', label='label here')
plt.legend(loc='best')
plt.show()
You can keep adding plt.plot
as many times as you like. As for line type
, you need to first specify the color. So for blue, it's b
. And for a normal line it's -
. An example would be:
plt.plot(total_lengths, sort_times_heap, 'b-', label="Heap")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…