Hello all,
Here is a bit of code that I am getting my head around. It's out of a
book that I am using to teach myself matplotlib, a python library for
making graphs etc.
The following code is using an object-orientated approach in
preparation for embedding the graph within an GUI application.
<code>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(0, 10, 0.1)
y = np.random.randn(len(x))
fig = plt.figure()
ax = fig.add_subplot(111)
l, = plt.plot(x, y)
t = ax.set_title('random numbers')
plt.show()
</code>
The line
l, = plt.plot(x, y)
has got me slighty confused because
l = plt.plot(x, y)
also works, without the trailing comma after the l
I was wondering if any Python coders might comment to the comma's
significance. I've scanned my four books on Python and can't find any
reference.
Cheers,
Chris