eliocamp / metR

Tools for Easier Analysis of Meteorological Fields
https://eliocamp.github.io/metR/
139 stars 22 forks source link

Default to `name = waiver()` on `scale_*_latitude()` and `scale_*_longitude()` #168

Closed brunomioto closed 1 year ago

brunomioto commented 1 year ago

It should be name = waiver() by default just like ggplot2, because axis.title just disappears when use scale_*_lat/lon() without any warning

# packages
library(ggplot2)
library(ggmap)
library(metR)

# get map
m <- get_map(location=c(lon=0,lat=0),zoom=5)

# create map - default
ggmap(m) +
  labs(
    x = "New Longitude title",
    y = "New Latitude title"
  )+
  scale_x_longitude(breaks = seq(-10,10,5)) +
  scale_y_latitude(breaks = seq(-10,10,5))
#> Scale for x is already present.
#> Adding another scale for x, which will replace the existing scale.
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.


# create map - with names
ggmap(m) +
  labs(
    x = "New Longitude title",
    y = "New Latitude title"
  )+
  scale_x_longitude(breaks = seq(-10,10,5), name = waiver()) +
  scale_y_latitude(breaks = seq(-10,10,5), name = waiver())
#> Scale for x is already present.
#> Adding another scale for x, which will replace the existing scale.
#> Scale for y is already present.
#> Adding another scale for y, which will replace the existing scale.

Created on 2022-11-29 with reprex v2.0.2

eliocamp commented 1 year ago

The default is to not to add a title since when drawing a map it's fairly obvious what the axis mean. Adding a scale always overrides labels set with labs(), but that's ggplot2 behaviour. Toy should always use labs() after the scales.