pyqtgraph automatically adds an item to the legend if it is created with the "name" parameter. The only adjustment needed in the above code would be as follows:
c3 = plt.plot (y=4, pen='y', name="maximum value")
as soon as you provide pyqtgraph with a name for the curve it will create the according legend item by itself.
It is important though to call plt.addLegend()
BEFORE you create the curves.