R中未渲染的情节地图 [英] Plotly Maps Not Rendering in R

查看:97
本文介绍了R中未渲染的情节地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功安装了R的plotly库.

I have successfully installed the plotly library for R.

要开始使用,我遵循了他们的R入门指南,并直接从我的RStudio 0.99.489版中的多个图中复制了代码.

To get started, I followed their Getting Started for R guide and directly copied the code from several plots in my RStudio Version 0.99.489.

散点图,箱形图等示例可以很好地工作.

The examples for scatterplots, box plots, etc. work well.

气泡图和Choropleth贴图的示例未正确绘制.地图根本不渲染.运行代码后,仅显示标题和图例.

The examples for bubble and choropleth maps do not plot properly. The maps do not render at all. Only title and legend show after running the code.

代码链接在这里:

https://plot.ly/r/bubble-maps/

https://plot.ly/r/choropleth-maps/

任何人都可以帮忙吗?

提前谢谢.

工具:

R的Plotly库2.016

Plotly Library 2.016 for R

R Studio版本0.99.489

R Studio Version 0.99.489

R版本3.2.2

在Windows 7 Home 64上运行

Running on Windows 7 Home 64

一组代码尝试绘制Plotly气泡图(直接从其用户指南/代码示例中复制:

One set of code tried for a Plotly Bubble Map (copied straight from their user guide/code examples:

library(plotly)
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_us_cities.csv')
df$hover <- paste(df$name, "Population", df$pop/1e6, " million")

df$q <- with(df, cut(pop, quantile(pop)))
levels(df$q) <- paste(c("1st", "2nd", "3rd", "4th", "5th"), "Quantile")
df$q <- as.ordered(df$q)

g <- list(
  scope = 'usa',
  projection = list(type = 'albers usa'),
  showland = TRUE,
  landcolor = toRGB("gray85"),
  subunitwidth = 1,
  countrywidth = 1,
  subunitcolor = toRGB("white"),
  countrycolor = toRGB("white")
)

plot_ly(df, lon = lon, lat = lat, text = hover,
        marker = list(size = sqrt(pop/10000) + 1),
        color = q, type = 'scattergeo', locationmode = 'USA-states') %>%
  layout(title = '2014 US city populations<br>(Click legend to toggle)', geo = g)

EDIT#2

我将问题隔离到这里:

plot_ly(df, lon = lon, lat = lat, text = hover,
        marker = list(size = sqrt(pop/10000) + 1),
        color = q, type = 'scattergeo', locationmode = 'USA-states')

我不确定如何从此处进行故障排除或简化语法以查看可能发生的情况.

I'm not sure how to troubleshoot from here or simplify the syntax to see what might be happening.

推荐答案

我在RStudio Viewer中以绘图方式绘制Choropleth贴图时遇到了类似的麻烦.甚至完全按照您在忠实网站的链接中提供的代码复制代码,也只给了我一个标题和图例,而没有提供地图.

I have had similar troubles with plotly rendering choropleth maps in the RStudio Viewer. Even copying the code exactly as provided in your links to the ployly website gave me just a title and legend, but no map.

但是,当我使用在新窗口中显示"按钮展开查看器时,在完全渲染的Web浏览器中打开了弧度.

However, when I expanded the Viewer using the "Show in new window" button, the choropleth opens up in my web brower fully rendered.

这使我相信问题是:

  1. 与plotly包本身有关的某些事情在RStudio的环境中无法正常工作(这就是疑问),或者,
  2. 这只是其中一些实例之一,因为查看器"窗口的尺寸过小,因此无法渲染图.如果我在具有大量相关性的大数据帧上运行成对"之类的事情,就会发生这种情况.除非我将其扩展为更大的尺寸或在浏览器窗口中呈现它,否则它不会在查看器中显示.

我想知道RStudio或软件包本身中是否有任何设置可以解决此问题.

I would like to know if there are any settings either in RStudio or in the packages themselves that may fix this.

编辑:在笔记本电脑上-仅在台式机上渲染图时,我没有遇到此问题.我相信两者都运行最新的R/RStudio版本,所以我不确定为什么要渲染而没有渲染.

EDIT: I do not encounter this issue when rendering the plot on my laptop -- just my desktop. I believe both are running the latest R/RStudio versions so I'm not sure why one renders and one does not.

这篇关于R中未渲染的情节地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆