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")
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:
Does anyone know how I can get rid of this grey space???
R version 3.0.0 Platform: i386-w64-mingw32/i386 (32-bit)
You got warning about the already present x axis because function autoplot.OpenStreetMap() (actually called by autoplot()) already has scale_x_continuous() defined. So you are making new x axis.
You can remove gray area just by adding argument expand=c(0,0) to your scale function. This argument is included in scale function that autoplot() uses.
+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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With