简体   繁体   English

在 Jupyter 中使用 R 绘制图形很慢

[英]Plotting graphs using R in Jupyter is slow

I am plotting heavy graphs in Jupyter using the language R. It is extremely slow as I expect it is first exporting it into EPS and then converting it to a png.我正在使用 R 语言在 Jupyter 中绘制大量图形。它非常慢,因为我希望它首先将其导出为 EPS,然后将其转换为 png。

If you try to plot on a native R setup ( R for windows for example ) the plotting is nearly instantaneous.如果您尝试在本机 R 设置(例如 Windows 中的 R)上绘图,则绘图几乎是即时的。

Is there a way to get R in Jupyter to plot more quickly?有没有办法让 Jupyter 中的 R 更快地绘图?

I came here looking for a solution to a potentially related issue-- the browser window became relatively unresponsive with lots of lag when drawing plots with a lot of datapoints, likely because everything was being rendered as vector graphics.我来这里是为了寻找一个潜在相关问题的解决方案——在绘制具有大量数据点的绘图时,浏览器窗口变得相对无响应并出现大量滞后,这可能是因为所有内容都被渲染为矢量图形。

In trying to solve my problem, it sped up initial drawing of graphs by an appreciable amount as well.在尝试解决我的问题时,它也显着加快了图形的初始绘制速度。 The solution was to change the jupyter plot output type to png using the command:解决方案是使用以下命令将 jupyter 绘图输出类型更改为 png:

options(jupyter.plot_mimetypes = 'image/png')

Now when I plot graphs with 10s of thousands of points, the window remains crisply responsive.现在,当我用成千上万个点绘制图形时,窗口保持清晰响应。 The downside is that the plots are now bitmap, but you can always remove the options if you want vector graphics.缺点是绘图现在是位图,但如果你想要矢量图形,你可以随时删除这些选项。

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

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