3

I'm trying to manipulate the axis tick marks in a UK map

map = openmap(upperLeft = c(60,-11), 
              lowerRight = c(49.5,3), type="mapquest-aerial")
map2 <- openproj(map)
autoplot(map2) +
  xlab("Longitude") + ylab("Latitude")

enter image description here I tried adding something like this:

  scale_x_continuous(breaks=seq(-10,2,2), labels=paste(c(rev(seq(0,10,2)),2),c(rep("°W",5),"°","°E"),sep=""))

I will get an error message: Scale for 'x' is already present. Adding another scale for 'x', which will replace the existing scale.

(probably because the scale is set in the map object) and although it does append the labels, the axis get shifted and a gap is created left and right of the plot: enter image description here Does anyone know how I can get rid of this grey space???

R version 3.0.0 Platform: i386-w64-mingw32/i386 (32-bit)

4

1 回答 1

4

您收到关于已经存在的 x 轴的警告,因为函数autoplot.OpenStreetMap()(实际上由 调用autoplot())已经scale_x_continuous()定义。所以你正在制作新的x轴。

您只需向expand=c(0,0)scale 函数添加参数即可删除灰色区域。此参数包含在autoplot()使用的比例函数中。

 +scale_x_continuous(breaks=seq(-10,2,2), labels=paste(c(rev(seq(0,10,2)),2),
                                c(rep("°W",5),"°","°E"),sep=""),expand=c(0,0))
于 2013-10-10T09:49:47.320 回答