I thought this was a very interesting question, so I thought I'd play around with it. I don't have a particularly deep understanding of what goes on behind the scenes in ggplot2
, but it seemed simple enough to just try and see what happens...
library(ggplot2)
data(iris)
iris[, "elm"] <- as.character(iris[, "Species"])
class(iris[, "elm"]) <- "elmstedt"
scale_type.elmstedt <- function(x, ...) {
c("elmstedt")
}
scale_type(iris[, "elm"])
#> [1] "elmstedt"
scale_type(iris[, "Species"])
#> [1] "discrete"
# template for scale_colour_elmstedt
scale_colour_discrete
#> function (..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0,
#> direction = 1, na.value = "grey50", aesthetics = "colour")
#> {
#> discrete_scale(aesthetics, "hue", hue_pal(h, c, l, h.start,
#> direction), na.value = na.value, ...)
#> }
#> <bytecode: 0x0000000013a5c328>
#> <environment: namespace:ggplot2>
scale_colour_elmstedt <- function(...,
h = c(0, 360),
c = 100,
l = 40,
h.start = 0,
direction = 1,
na.value = "grey50",
aesthetics = "colour") {
discrete_scale(aesthetics,
"hue",
scales::hue_pal(h, c, l, h.start, direction),
na.value = na.value,
...
)
}
# Plots
ggplot(iris, aes(Sepal.Width, Sepal.Length, color = Species)) +
geom_point(size = 3)

ggplot(iris, aes(Sepal.Width, Sepal.Length, color = elm)) +
geom_point(size = 3)

Created on 2020-09-01 by the reprex package (v0.3.0)
This honestly would have taken all of about 5 minutes to try if I had remembered hadley is a Kiwi! I originally named the function custom scale function scale_color_elmstedt
, which ggplot2
was happy to ignore aside from throwing the occasional error my way for over an hour while I dug through the ggplot2
source on GitHub... So, make sure you always foullouw an "o" with a "u" our you'll be pounished four your bad behaviour. 
All joking aside, if ggplot2
will pick it up out of the global environment, there's no reason I can imagine it wouldn't find it elsewhere in the search path (e.g. in a loaded package).