使用积点图的交互式地图会显示经度和纬度需要作为数据点,并且不适用于2个组合图

问题描述

这是我的代码-第一个问题,我无法将两个情节结合起来,其次我正在努力使用plotly使其互动。我的数据格式也包括在这里

Data

mapind <- read.csv("V2_tobacco_cancer_india2017.csv",header=T)
head(mapind)
attach(mapind)

mapBox.ind <- c(68.3,7.5,97.4,37.12)
mycol <- rgb(255,max = 255,alpha = 120,names = "red50")
mycol1 <- rgb(0,names = "blue50")
mycol2 <- rgb(0,255,names = "yellow50")
mycol3 <- rgb(34,139,34,names = "brown50")

inmap <- get_stamenmap(bBox=mapBox.ind,maptype="toner-lite",color = "color",zoom=6,crop=T,force=T)


p1 <- ggmap(inmap) +
  geom_point(data = mapind,aes(Long,Lat),col = mycol,cex = 0.3*SLT_Prevalence,pch = 16,show.legend = T) +
  geom_point(data = mapind,col = mycol1,cex = 0.3*Pharynx_Oral_cancer,show.legend = T) +
  geom_label_repel(data = mapind,aes(mapind$Long,mapind$Lat),label = states,size = 2,color = "black",nudge_y = -0.6,nudge_x = -0.6,fontface = "bold",segment.color = NA) +
  # geom_label_repel(data = mapind,nudge_y = 0,nudge_x = 0,segment.color = NA) +
  ggtitle("B) Smokeless tobacco (red) and Oral Cancer (black)") +
  theme(plot.title = element_text(size = 12)) +
  theme(axis.text=element_text(size=7),axis.title=element_text(size=7,face="bold")) +
  annotate("label",label = "10 Oral Cancer Cases per 100K",x = 91,y = 11.3) +
  annotate("label",label = "10% SLT Prevalence",y = 9.3)
  
p2 <- ggmap(inmap) +
  geom_point(data = mapind,col = mycol2,cex = 0.3*Smoking_Prevalence,col = mycol3,cex = 0.3*Lung_cancer,segment.color = NA) +
  ggtitle("A) Smoking (blue) and Lung Cancer (green)") +
  theme(plot.title = element_text(size = 12)) +
  theme(axis.text=element_text(size=7),label = "10 Lung Cancer Cases per 100K",label = "10% Smoking Prevalence",y = 9.3)

p <- grid.arrange(p2,p1,ncol=2,top = text_grob("Prevalence of Tobacco Use and Associated Cancer Rates in India",size = 14),bottom = text_grob("Source: Indian Council of Medical Research,Public Health Foundation of India,and Institute of Health Metrics and Evaluation 2017; Global Adult Tobacco Survey 2016-17",size = 9))
 
p <- ggarrange(p1,p2,labels = c("A","B"),ncol = 2,nrow = 1)

ggplotly(p1) %>%
  highlight(
    "plotly_hover",selected = attrs_selected(line = list(color = "black"))
  ) %>%
  widgetframe::frameWidget()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)