Matplotlib with Pydroid 3 on Android: how to see graph?

Question:

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.

Asked By: stari

||

Answers:

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.

Answered By: WDS

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()
Answered By: BlackRiver
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.

Answered By: user7102471

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

Answered By: stari

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 
Answered By: GregGold

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

import seaborn as sns
import matplotlib.pyplot as plt

%matplotlib inline
Answered By: Faust Alefstoun

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")

Answered By: Tirtharaj Pramanik

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
Answered By: razi-tm
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.