Issue
I am trying to show a plot to the notebook from a python script, but all I get is a text output showing me the type() output of the figure.I have something like this:
This is my script (a very simplified version of my actual script, but same concept).
import matplotlib.pyplot as plt
x=[1,2,3,4,5,6,5,3,2,4,2,3,4,2]
plt.plot(x)
plt.show()
I have also tried setting the backend to notebook, but I get the same result. If I plot some data from the console (writing python directly into the code textbox, the plot works fine). I have searched for the answer in a lot of forums, and even the official Google notebook to plotting in Colab says that the plot should work fine from within a script.
Solution
Instead of calling
!python plot.py
Use this instead
%run plot.py
It will show the plot normally.
Answered By - korakot
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.