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

8

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.

Feinstein answered 30/3, 2019 at 18:2 Comment(1)
Having the same problem. If you import matplotlib you lose access to the terminal, so cant see anything printedCauline
F
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

Feinstein answered 16/3, 2020 at 8:25 Comment(0)
P
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.

Principate answered 27/5, 2019 at 10:25 Comment(1)
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)Cauline
P
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.

Pulque answered 18/9, 2019 at 9:11 Comment(0)
L
1

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

import seaborn as sns
import matplotlib.pyplot as plt

%matplotlib inline
Linda answered 29/1, 2021 at 23:18 Comment(0)
C
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()
Craw answered 3/9, 2019 at 10:17 Comment(1)
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.Craw
F
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

Feinstein answered 16/3, 2020 at 8:25 Comment(0)
T
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 
Technicality answered 22/9, 2020 at 23:34 Comment(0)
T
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")

Tabber answered 26/2, 2021 at 13:34 Comment(0)
G
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
Gouge answered 9/6, 2021 at 6:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.