繁体   English   中英

您能否将表格绘制到类似于非笛卡尔坐标的 annotation_custom 方法的 ggmap 上

[英]Can you plot a table onto a ggmap similar to annotation_custom method for non- Cartesian coordinates

我一直在玩 ggplot2,发现在 r 中 ggplot 的绘图区域内添加表

我想知道是否有任何方法可以使用非笛卡尔坐标进行绘图,例如,是否使用地图坐标来定位表格。 我有一些地图,并认为如果他们可以将相应的数据放在表格中以显示更多细节,那会很酷。

如果有人知道非笛卡尔坐标的 annotation_custom 的解决方法,将不胜感激。

编辑:这是我的地图外观的图像,我只是在想是否有另一种方法可以在此左侧绘制表格。在此处输入图片说明

编辑:这是我试图做的在此处输入图片说明

编辑:这是情节的基本代码结构

library(ggplot2)
library(ggmap)

plotdata <- read.csv("WellSummary_All_SE_NRM.csv", header = T)
plotdata <- na.omit(plotdata)
plotdata <- plotdata[1:20, c("Unit_No","neg_decimal_lat", "decimal_long", "max_drill_depth", "max_drill_date")]
map.plot<- get_map(location = c(min(plotdata$decimal_long),
                                min(plotdata$neg_decimal_lat),
                                max(plotdata$decimal_long),
                                max(plotdata$neg_decimal_lat)),
                   maptype ="hybrid",source = "google", zoom=8)
theme_set(theme_bw(base_size = 8))
colormap <- c("darkblue","blue","lightblue", "green", "yellow", "orange","darkorange", "red", "darkred")
myBreaks <- c(0,2, 10, 50, 250, 1250, 2000, 2500)
static.map <- ggmap(map.plot) %+% plotdata + 
  aes(x = decimal_long,
      y = neg_decimal_lat,
      z= max_drill_depth)+
  stat_summary2d(fun = median, binwidth = c(.03, .03),alpha = 0.7) + 
  scale_fill_gradientn(name = "depth", colours= colormap, breaks=myBreaks,labels = format(myBreaks),
                       limits= c(0,2600), space = "Lab") + 
  labs(x = "Longitude",y = "Latitude")+
  geom_text(aes(label=Unit_No),hjust=0, vjust=0,size=2,
            position = position_dodge(width=0.9), angle = 45)+ 
  coord_map()     

#Creates image of the plot in file to Working Directory
filename=paste("2dmap",".png", sep="")
cat("\t",filename,"file created, saving...\n")
print(static.map)
cat("\tpassed mapping, file now being made\n")
ggsave(filename=filename,
       plot = static.map,
       scale = 1,
       width = 6, height = 4,
       dpi = 300)

我今天会尝试上传数据,已经为一些指针欢呼了!

我已经上传了数据,不用担心梯度值和文本标签的位置,因为我可以稍后修复它们我还将链接当前的 ggmap 代码,但我使用了一个非常大的循环来对数据进行排序。

https://drive.google.com/file/d/0B8qOIJ-nPp9rM1U1dkEzMUM0Znc/edit?usp=sharing

尝试这个,

library(gridExtra)
grid.arrange(tableGrob(head(iris)), qplot(1,1), ncol=2)

annotation_custom无济于事,它用于在绘图面板内添加内容,而不是添加到侧面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM