I'm programming in python and I work on OS Yosemite with Anaconda: Conda Version: 3.15.1, Python Version: 3.4.3.final.0 and I have this problem with plot:
import matplotlib.pyplot as plt
a=[1,2,3]
b=[10,20,30]
plt.plot(a,b)
plt.show()
but I have the error: []. I read some other question about the same problem but I have not resolved my problem. Thanks in advance. Giuseppe
You can try this before import
%matplotlib inline
That isn't an error message. plt.plot returns a list of matplotlib.lines.Line2D objects. That object gets printed by the interpreter as:
<matplotlib.lines.Line2D object at ...>
This format is how the interpreter prints everything that doesn't have a method __repr__.
Its exactly the same as this example
>>> def f():
... return 42
...
>>> f()
42
Possibly these two classes might be a bit more illuminating:
>>> class C():
... def __init__(self):
... self.meaning_of_life = 42
...
>>> class D():
... def __init__(self):
... self.meaning_of_life = 42
... def __repr__(self):
... return "Meaning = {}".format(self.meaning_of_life)
...
>>> C()
<__main__.C object at 0x7f4a3255b8d0>
>>> D()
Meaning = 42
If the plot isn't showing then there is a problem elsewhere but it isn't related to that message (which should get printed after you call plt.plot not plt.show anyway).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With