本文介绍了在ggmap的地图中调整字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我试图在德国地图上绘制多个点,使用ggmap包,效果很好。但是,我想做一些具体的改变,不知道如何或者如果这是可能的。 为了制作地图,我做了以下工作(d是一个有经度和纬度的数据框): map p p < -p + scale_x_continuous(极限= c(6.09500,14.95306))+ scale_y_continuous(极限= c(47.39889,55.01250)+ c(0,-0.1))p 在那张地图上,我绘制了一些点。现在,如果我像上面那样设置zoom = 6,那么地图非常详细,并且会打印大量城市名称以及一些道路白线。这使地图看起来有点拥挤。以下是地图的样子: pdf的大小也相当大,这不是如果我想要有多个地图,非常实用。 另一方面,如果我设置zoom = 5,则背景不太详细,并且文件较小。但是,城市和国家名称的印刷字体太大。以下是它的样子: 所以我的问题是:可以以某种方式得到一个地图,详细信息如缩放= 5,但与国家和城市名称的字体大小在缩放= 6? 预先感谢 get_googlemap ,您可以将字符串传递给样式参数,该参数将传递给Google Static Maps API。请参阅 如果您想要更多标签,稍后可以更容易地将它们插入R.随意调整。 I am trying to plot a number of points on a map of Germany, using the ggmap package, which works great. However, I would like to make some specific changes and do not know how to or if that is at all possible.To make the maps, I do the following (d is a data frame with longitudes and latitudes):map <- get_map(location = c(10.25828, 51.11484), zoom = 6, maptype = "terrain")p <- ggmap(map)p <- p + scale_x_continuous(limits = c(6.09500,14.95306)) + scale_y_continuous(limits = c(47.39889,55.01250)+c(0,-0.1))p <- p + xlab("Longitude") + ylab("Latitude")On that map, I then plot some points. Now, if I set zoom = 6 as above, then the map is very detailed, and lots of city names are printed, along with some white lines for the roads. This makes the map look a bit too "crowded". Here is what the map looks like:The size of the pdf is also quite large which is not very practical if I want to have multiple maps.On the other hand, if I set zoom = 5, then the background is less detailed, less roads etc are shown, and the file is smaller. However, the printed font of the city and country names is too large. Here is what it looks like:So my question is: Can is somehow get a map with details as in zoom = 5, but with the font size of country and city names as in zoom = 6?Thanks in advance 解决方案 If you change from get_map to get_googlemap, you can pass a string to the style argument which will get passed to the Google Static Maps API. See the documentation, and a crucial reference.I don't think you can change text size, but you can simplify roads and remove certain labels like so:map <- get_googlemap(center = c(10.25828, 51.11484), zoom = 6, maptype = "terrain", style = 'feature:road|element:all|visibility:simplified&style=feature:administrative.locality|element:labels|visibility:off')which returnsIf you want more labels, it's probably easier to insert them later in R. Adjust as you like. 这篇关于在ggmap的地图中调整字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-05 06:37