R如何扩大ggmap的水平范围
R How to expand the horizontal range of ggmap
我正在尝试使用 ggmap 在地图上映射位置数据。这些点由纬度和经度定义,并分布在很宽的经度范围内。但是,ggmap 只允许方框。
您可以在此处下载位置数据:https://www.dropbox.com/s/2s33ccpu4m3vsl9/data.csv?dl=0
我用来生成地图的代码如下:
geoCodes <- geocode("Kazan, Russia")
map = get_googlemap(
center=c(geoCodes$lon,geoCodes$lat), #Long/lat of centre
zoom=3,
maptype='roadmap', #also hybrid/terrain/roadmap
scale = 2)
data = data.frame (testTrain$lon_1, testTrain$lat_1,testTrain$isDuplicate)
ggmap(map, extent='normal', size = c(900, 900)) + geom_point (data = data,
aes (
x = testTrain$lon_1,
y = testTrain$lat_1,
fill = factor (testTrain$isDuplicate)
),
pch = 21,
colour = "white",
size = 2,
alpha = 0.4
) +
scale_fill_brewer (palette = "Set1", name = "Duplicates") +
theme (
legend.position = c(0.05, 0.05), # put the legend INSIDE the plot area
legend.justification = c(0, 0),
legend.background = element_rect(colour = F, fill = "white"),
legend.key = element_rect (fill = F, colour = F),
panel.grid.major = element_blank (), # remove major grid
panel.grid.minor = element_blank (), # remove minor grid
axis.text = element_blank (),
axis.title = element_blank (),
axis.ticks = element_blank ()
)
有没有办法扩大ggmap的范围,使其覆盖更广的区域?
scale_y_continuous()
选项将允许您 trim 使图形显示为矩形
ggmap( get_googlemap(
center = c(lon = 37.6173, lat = 55.7558), #Long/lat of centre
zoom=3,
size=c(600,600),
maptype='roadmap', #also hybrid/terrain/roadmap
scale = 2)
)+ scale_y_continuous(limits=c(30, 60))
我正在尝试使用 ggmap 在地图上映射位置数据。这些点由纬度和经度定义,并分布在很宽的经度范围内。但是,ggmap 只允许方框。
您可以在此处下载位置数据:https://www.dropbox.com/s/2s33ccpu4m3vsl9/data.csv?dl=0
我用来生成地图的代码如下:
geoCodes <- geocode("Kazan, Russia")
map = get_googlemap(
center=c(geoCodes$lon,geoCodes$lat), #Long/lat of centre
zoom=3,
maptype='roadmap', #also hybrid/terrain/roadmap
scale = 2)
data = data.frame (testTrain$lon_1, testTrain$lat_1,testTrain$isDuplicate)
ggmap(map, extent='normal', size = c(900, 900)) + geom_point (data = data,
aes (
x = testTrain$lon_1,
y = testTrain$lat_1,
fill = factor (testTrain$isDuplicate)
),
pch = 21,
colour = "white",
size = 2,
alpha = 0.4
) +
scale_fill_brewer (palette = "Set1", name = "Duplicates") +
theme (
legend.position = c(0.05, 0.05), # put the legend INSIDE the plot area
legend.justification = c(0, 0),
legend.background = element_rect(colour = F, fill = "white"),
legend.key = element_rect (fill = F, colour = F),
panel.grid.major = element_blank (), # remove major grid
panel.grid.minor = element_blank (), # remove minor grid
axis.text = element_blank (),
axis.title = element_blank (),
axis.ticks = element_blank ()
)
有没有办法扩大ggmap的范围,使其覆盖更广的区域?
scale_y_continuous()
选项将允许您 trim 使图形显示为矩形
ggmap( get_googlemap(
center = c(lon = 37.6173, lat = 55.7558), #Long/lat of centre
zoom=3,
size=c(600,600),
maptype='roadmap', #also hybrid/terrain/roadmap
scale = 2)
)+ scale_y_continuous(limits=c(30, 60))