R plotly orca错误:找不到映射框访问令牌

时间:2018-12-12 15:32:13

标签: r docker electron r-plotly orca

我阅读了教程https://github.com/plotly/orca#installation,并在docker image中运行命令:

apt-get install -y curl && \
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - && \
apt-get install -y nodejs libgconf-2-4 libgtk2.0-0 && \
npm install -g electron@1.8.4 orca --unsafe-perm=true --allow-root

操作系统详细信息:

root@8a17254aeb9a:/# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 9.6 (stretch)
Release:    9.6
Codename:   stretch

但是执行时什么也没发生:

root@8a17254aeb9a:/# which orca
/usr/bin/orca
root@8a17254aeb9a:/# orca
root@8a17254aeb9a:/# orca --help
root@8a17254aeb9a:/# electron
root@8a17254aeb9a:/# electron -v

当我执行示例R代码时,出现错误:

> library(plotly)
> p <- plot_ly(z = ~volcano) %>% add_surface()
> orca(p, "surface-plot.svg")
Error: No mapbox access token found. Obtain a token here
https://www.mapbox.com/help/create-api-access-token/
Once you have a token, assign it to an environment variable 
named 'MAPBOX_TOKEN', for example,
Sys.setenv('MAPBOX_TOKEN' = 'secret token')

我阅读了很多教程和问题,但仍然没有答案。你能帮忙吗?

1 个答案:

答案 0 :(得分:2)

如果您遵循安装说明并指定了命令行orca,则可以通过分配一个随机数来解决“未找到映射箱访问令牌” 的问题:

library(plotly)
Sys.setenv(MAPBOX_TOKEN = 11122223333444) # it doesn't matter what number I put!

p <- plot_ly(x = 1:10, y = 1:10, color = 1:10)
orca(p, format = "svg", "plot.svg")

这用于使用plotly (4.8.0)orca (1.2.1-1)存储本地高质量图像。

P.S .:如果您安装 plotly的最新版本(我用4.8.9000进行了测试),则无需设置随机mapbox令牌即可使用。通过以下方式安装最新版本:devtools::install_github('ropensci/plotly')