5

I'm currently using an Android device (of Samsung), Pydroid 3.
I tried to see any graphs, but it doesn't works.
When I run the code, it just shows me a black-blank screen temporarily and then goes back to the source code editing window.
(means that i can't see even terminal screen, which always showed me [Program Finished])

Well, even the basic sample code which Pydroid gives me doesn't show me the graph :(
I've seen many tutorials which successfully showed graphs, but well, mine can't do that things.
Unfortunately, cannot grab any errors.
Using same code which worked at Windows, so don't think the code has problem.
Of course, matplotlib is installed, numpy is also installed.
If there's any possible problems, please let me know.

stari
  • 73
  • 1
  • 1
  • 7

8 Answers8

3

I also had this problem a while back, and managed to fix it by using plt.show() at the end of your code. With matplotlib.pyplot as plt.

WDS
  • 337
  • 3
  • 16
  • while this fixes the showing problem, you still cant see the terminal with this (in case you wanted to show some info if the graph isn't what you expected) – Dániel Kovács Feb 12 '20 at 19:55
3
import matplotlib.pyplot as plt

#draw something

plt.savefig("picturename.png")

Then you can find the picture file in your disk and open them manual.

user7102471
  • 75
  • 1
  • 1
  • 6
0

I'm having similar problem with matplotlib in Pydroid3. My cellphone is a Motorola. In my case, the code executes completely without errors, but the plot window even opens. Follow my code (of course seaborn (as sns) was installed and imported, as much matplotlib.pyplot as plt):

sns.regplot(x=score,y=target,data=df)
plt.show()
BlackRiver
  • 23
  • 6
  • It worked. It was not exactly what I had in mind because there are some graphs to be plotted and I was expecting to see then as a pop up window. – BlackRiver Oct 25 '19 at 09:48
0

After reinstalling it worked.

The problem was that I forced Pydroid to update matplotlib via Terminal, not the official PIP tab.
The version of matplotlib was too high for pydroid

stari
  • 73
  • 1
  • 1
  • 7
0

Yep, for Android I used as below and it worked :

#plt.show() // just comment out as it may not display from Pydroid Terminal anyway 

plt.savefig('yourplot.jpg') // save plot as Jpeg file for Android 

plt.close() // close matlab plotting 
Markus
  • 2,265
  • 5
  • 28
  • 54
0

I got same problem. Add "%matplotlib inline" while importing mathplotlib and/or seaborn.

import seaborn as sns
import matplotlib.pyplot as plt

%matplotlib inline
Dharman
  • 30,962
  • 25
  • 85
  • 135
0

You just need to add a line

plt.show()

Then it will work. You can also save the file before showing

plt.savefig("*imageName*.png")

Tolio
  • 1,023
  • 13
  • 30
0

like was said in other answers plt.show and plt.savefig will do the job; but when I wanted to see help(documentation) of matplotlib.pyplot, that wasn't working. so I saved my program and then run it in terminal:

import matplotlib.pyplot as plt

help (plt)

for example we can save it in newfile.py and doing this in terminal:

python newfile.py
StupidWolf
  • 45,075
  • 17
  • 40
  • 72
razi-tm
  • 1
  • 1