简体   繁体   English

Android 上带有 Pydroid 3 的 Matplotlib:如何查看图形?

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

I'm currently using an Android device (of Samsung), Pydroid 3.我目前正在使用 Android 设备(三星)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 :(好吧,即使是 Pydroid 给我的基本示例代码也没有向我展示图表:(
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.使用在 Windows 上工作的相同代码,所以不要认为代码有问题。
Of course, matplotlib is installed, numpy is also installed.当然安装了matplotlib,也安装了numpy。
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. plt.show()我也遇到了这个问题,并通过在代码末尾使用plt.show()设法修复了它。 With matplotlib.pyplot as plt.使用 matplotlib.pyplot 作为 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.我在 Pydroid3 中遇到 matplotlib 类似的问题。 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):按照我的代码(当然seaborn(如sns)已安装并导入,matplotlib.pyplot和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.问题是我强迫 Pydroid 通过终端更新 matplotlib,而不是官方的 PIP 选项卡。
The version of matplotlib was too high for pydroid matplotlib 的版本对于 pydroid 来说太高了

Yep, for Android I used as below and it worked :是的,对于 Android,我使用如下并且它有效:

#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.在导入 mathplotlib 和/或 seaborn 时添加“%matplotlib inline”。

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;就像其他答案中所说的那样 plt.show 和 plt.savefig 将完成这项工作; but when I wanted to see help(documentation) of matplotlib.pyplot, that wasn't working.但是当我想查看 matplotlib.pyplot 的帮助(文档)时,这不起作用。 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:例如,我们可以将其保存在newfile.py并在终端中执行此操作:

python newfile.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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