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

1st Apr 2022, 7:11 AM
Ahmed Yahya
Ahmed Yahya - avatar
9 Respuestas
+ 1
Maybe. The reason why plt.show() is not working on Sololearn might be because of a dependency issue.
1st Apr 2022, 8:25 AM
Orisa
Orisa - avatar
+ 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.
1st Apr 2022, 3:49 PM
Simon Sauter
Simon Sauter - avatar
+ 1
Can you share your full code and give more details about what you are trying to display?
1st Apr 2022, 7:43 AM
Orisa
Orisa - avatar
1st Apr 2022, 7:52 AM
Ahmed Yahya
Ahmed Yahya - avatar
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
1st Apr 2022, 8:18 AM
Orisa
Orisa - avatar
0
don't use # in line 4 it may works here my point is plot.show removing doesn't make difference while sololearn adds
1st Apr 2022, 8:20 AM
Ahmed Yahya
Ahmed Yahya - avatar
0
I still get the graph by uncommenting it in my IDE. Either show() or savefig() displays your figure and axes for me.
1st Apr 2022, 8:22 AM
Orisa
Orisa - avatar
0
so it depends on IDE ?
1st Apr 2022, 8:24 AM
Ahmed Yahya
Ahmed Yahya - avatar
0
i deducted that i didn't try it yet using different IDE
1st Apr 2022, 3:51 PM
Ahmed Yahya
Ahmed Yahya - avatar