未呈現,我已經成功地安裝了R.Plotly地圖中的R
的plotly庫要開始,我跟着他們入門的R引導和直接複製從幾個地塊的代碼在我RStudio版本0.99.489 。
的散點圖,箱線圖,等例子很好地工作。
氣泡和等值線圖的示例不正確繪製。地圖根本不渲染。運行代碼後只顯示標題和圖例。
鏈接的代碼在這裏:
https://plot.ly/r/bubble-maps/
https://plot.ly/r/choropleth-maps/
誰能幫助?
在此先感謝。
編輯:
工具:
Plotly庫2.016的R
[R Studio版本0.99.489
[R版本3.2.2
運行在Windows 7家庭64
一組代碼嘗試了Plotly泡泡地圖(從他們的用戶指南/代碼示例直複製:
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)
編輯#2
我已經找出問題在這裏:
plot_ly(df, lon = lon, lat = lat, text = hover,
marker = list(size = sqrt(pop/10000) + 1),
color = q, type = 'scattergeo', locationmode = 'USA-states')
我不知道如何從這裏排除故障或簡化語法以查看可能發生的情況。
請包括重現錯誤的工具版本和代碼,否則這只是猜測工作可能不值得的時間。 –
@RomanLuštrik請參閱我的編輯。我已包括所有。對於之前沒有這樣做的道歉。 – Windstorm1981
發佈中的代碼適用於我。 – MLavoie