Skip to content
Advertisement

matplotlib 2d line line,=plot comma meaning

I’m walking through basic tutorials for matplotlib, and the example code that I’m working on is:

JavaScript

Does anyone know what the comma after line (line,=plt.plot(x,y,'-')) means? I thought it was a typo but obviously the whole code doesn’t work if I omit the comma.

Advertisement

Answer

plt.plot returns a list of the Line2D objects plotted, even if you plot only one line.

That comma is unpacking the single value into line.

ex

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement