+ 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 ! ! !

20th Sep 2024, 5:20 PM
ᎢㅤᏆㅤᎷㅤᎬㅤ✨
ᎢㅤᏆㅤᎷㅤᎬㅤ✨ - avatar
4 Respuestas
+ 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.
20th Sep 2024, 5:49 PM
Brian
Brian - avatar
+ 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
20th Sep 2024, 7:19 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
0
ᎢㅤᏆㅤᎷㅤᎬㅤ✨ here is an example on how to view pyplot graphs in Sololearn https://sololearn.com/compiler-playground/cTO4FCnly74N/?ref=app
23rd Sep 2024, 1:55 AM
Bob_Li
Bob_Li - avatar
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.
25th Sep 2024, 10:57 AM
Евгений
Евгений - avatar