matplotlib in spyder - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: matplotlib in spyder (/thread-10060.html) |
matplotlib in spyder - Scott - May-11-2018 Hi everyone, When I type the below code I get the following output but no graph visual. How do I display graphs with matplotlib when using spyder? import matplotlib.pyplot as plt import numpy as np data = np.arange(10) data plt.plot(data)<IPython.core.display.Javascript object> <IPython.core.display.HTML object> Out[3]: [<matplotlib.lines.Line2D at 0x2610f7bc198>] RE: matplotlib in spyder - Larz60+ - May-11-2018 for interactive: import matplotlib.pyplot as plt import numpy as np data = np.arange(10) data plt.plot(data) plt.show() RE: matplotlib in spyder - Scott - May-11-2018 It still does not work. Sorry I forgot to add one line of code. import numpy as np data = np.arange(10) data plt.plot(data) fig = plt.figure()I tried adding plt.show() [python] import matplotlib.pyplot as plt import numpy as np data = np.arange(10) data plt.plot(data) fig = plt.figure() plt.show() [\python] RE: matplotlib in spyder - Larz60+ - May-11-2018 You didn't import matplotlib.pyplot Works fine for me Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib.pyplot as plt >>> import numpy as np >>> data = np.arange(10) >>> data array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> plt.plot(data) [<matplotlib.lines.Line2D object at 0x000000000A894F60>] >>> fig = plt.figure() >>> plt.show()Results in image: [attachment=408] RE: matplotlib in spyder - Scott - May-11-2018 It worked now, thanks. |