R ggmap:为什么我可以使用filename属性创建矩形地图,但不能在绘图中使用它们? [英] R ggmap: Why can I create rectangular maps using the filename attribute, but not use them in a plot?

查看:84
本文介绍了R ggmap:为什么我可以使用filename属性创建矩形地图,但不能在绘图中使用它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在R中创建一个世界地图.我对ggmap有点熟悉,所以我尝试了如下操作:

I would like to create a world map in R. I'm somewhat familiar with ggmap, so I tried something like this:

ggmap(get_googlemap(center=c(83,25),
                    zoom=1, scale=4, filename="world", size=c(640,300)))

world.png而言,它确实可以正常工作.

It does work fine as far as the world.png is concerned.

我真的很高兴为ggmap的无法显示高于80°的纬度的东西"问题找到一种解决方法,由于这种解决方法,或多或少不可能创建整个世界的地图.

I was actually quite happy to have found a workaround for ggmap's "can't show anything above 80° latitude" issue, due to which it's more or less impossible to create maps of the whole world.

但是,在R本身(即绘图中)中,地图看起来并没有达到预期的样子:

However, in R itself, that is in the plots, the map looks not at all the way it's supposed to:

仅当地图是矩形(相应地设置了size属性)而不是正方形(这是默认设置)时,才会发生这种情况.

This only happens when the map is rectangular (when the size attribute is set accordingly), and not square (as would be the default).

那是为什么?将来是否有可能解决此问题? 从这里到正确的世界地图的最快方法是什么?

Why's that? Is there any chance that this issue will be resolved in the future? And what's the quickest way from here to a proper world map?

推荐答案

使用比例限制.

ggmap(get_map(location=c(28.978359,41.008240), zoom=13, scale="auto"))

ggmap(get_map(location=c(28.978359,41.008240), zoom=13, scale="auto")) +
    scale_x_continuous(limits = c(28.925,29.025), expand = c(0, 0)) +
    scale_y_continuous(limits = c(40.99,41.03), expand = c(0, 0))

这篇关于R ggmap:为什么我可以使用filename属性创建矩形地图,但不能在绘图中使用它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆