[英]Trying to add an image to a polar plot gives "Error: annotation_custom only works with Cartesian coordinates"
[英]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.