+ 1
Graphs Using Python
import matplotlib.pyplot as pp import numpy as np x=np.array([1,8]) y=np.array([3,10]) pp.plot(x,y) pp.show() Does solo learn don't support matplotlib or it is wrong . It is showing None 😭😔 Help ! ! !
4 Respostas
+ 5
On Sololearn you need an extra step. Save the plot as a .png file.
pp.savefig('plot.png')
Then their batch program will recognize that it needs to enable html display and it will show the image.
+ 3
just a note:
alias convension is plt (not pp)
just in case if you would like to do something for anybody else, or in a team...., or is you see someone's code
0
ᎢㅤᏆㅤᎷㅤᎬㅤ✨
here is an example on how to view pyplot graphs in Sololearn
https://sololearn.com/compiler-playground/cTO4FCnly74N/?ref=app
0
Just an addition to the Brian's answer. The name inside the `plt.savefig()` doesn't matter, you can even use an empty string, or use the same name if you generate several plots, they all will be displayed, and not overwritten.
Please note, however, that this is true only here on SoloLearn, because it alters the internals of the `plt.savefig()` function, so the plots could be displayed via the web interface. When running in a real interpreter, you still need to give it non-empty different filenames in order to work correctly.