0
matplotlib.pyplot.show()
when i remove show() from the code nothing happens while Solo always add it to the code so what is the point ? https://code.sololearn.com/cxNZ0biTl43s/?ref=app
9 Answers
+ 1
Maybe. The reason why plt.show() is not working on Sololearn might be because of a dependency issue.
+ 2
The normal command to display a plot is plt.show(). The plt.savefig() command saves the plot to a file.
In sololearn plt.show() does not work because sololearn doesn't support graphics (except in Web codes). I assume that they use it anyway because you need it outside of sl. To allow you to show plots anyway sl employs a workaround where you can save the plot in a (temporary) file which is then displayed.
+ 1
Can you share your full code and give more details about what you are trying to display?
0
That is strange. Your code does not run in the Sololearn Editor but works properly in my IDE (PyCharm).
import matplotlib.pyplot as plt
fig = plt.figure()
ax = plt.axes()
# plt.savefig('fig.png')
plt.show() # this line
I commented the plt.savefig line and still managed to display your graph. Maybe your code is not the issue here.
https://stackoverflow.com/questions/7534453/matplotlib-does-not-show-my-drawings-although-i-call-pyplot-show
0
don't use # in line 4
it may works here
my point is plot.show removing doesn't make difference while sololearn adds
0
I still get the graph by uncommenting it in my IDE. Either show() or savefig() displays your figure and axes for me.
0
so it depends on IDE ?
0
i deducted that i didn't try it yet using different IDE