Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
绘图地图悬停在';用R表示_R_Plotly - Fatal编程技术网

绘图地图悬停在';用R表示

绘图地图悬停在';用R表示,r,plotly,R,Plotly,使用from Plotly,地图悬停不会在RStudio(或使用RMarkdown编译的.html文件)中呈现: library(plotly)#版本“4.7.1” df我认为这是由于您正在使用的plot\ly的更新版本(不再需要hoverinfo=“text”): 试试这个: library(plotly) # version ‘4.7.1’ df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/

使用from Plotly,地图悬停不会在RStudio(或使用RMarkdown编译的.html文件)中呈现:

library(plotly)#版本“4.7.1”

df我认为这是由于您正在使用的plot\ly的更新版本(不再需要hoverinfo=“text”): 试试这个:

library(plotly) # version ‘4.7.1’
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_us_cities.csv')

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

p <- plot_geo(df, locationmode = 'USA-states', sizes = c(1, 250)) %>%  
  layout(title = '2014 US city populations<br>(Click legend to toggle)', geo = g) %>%  
  add_markers(x = ~lon, y = ~lat, size = ~pop, color = ~q, text = ~paste(df$name, "<br />", df$pop/1e6, " million")
              )  

p
library(plotly)#版本“4.7.1”

df我认为这是由于您正在使用的plot\ly的更新版本(不再需要hoverinfo=“text”): 试试这个:

library(plotly) # version ‘4.7.1’
df <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_us_cities.csv')

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

p <- plot_geo(df, locationmode = 'USA-states', sizes = c(1, 250)) %>%  
  layout(title = '2014 US city populations<br>(Click legend to toggle)', geo = g) %>%  
  add_markers(x = ~lon, y = ~lat, size = ~pop, color = ~q, text = ~paste(df$name, "<br />", df$pop/1e6, " million")
              )  

p
library(plotly)#版本“4.7.1”

df这最近在开发版本
devtools::install_github('ropensci/plotly')
这最近在开发版本
devtools::install_github('ropensci/plotly')中得到了修复。