简体   繁体   中英

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

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.

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.

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.

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

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

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 

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

import seaborn as sns
import matplotlib.pyplot as plt

%matplotlib inline

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM