-1

If I have something like:

ggplot() + geom_line(data = data,aes(x = x.data, y= y.data, color = color.data))

and I want the color to be on a log scale, how would I go about it?

jcholly
  • 37
  • 5

1 Answers1

4

You can add a continuous colour scale with trans = "log10". Example below:

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.1.1

ggplot(economics, aes(date, unemploy)) +
  geom_line(aes(colour = unemploy)) +
  scale_colour_viridis_c(trans = "log10")

Created on 2021-10-27 by the reprex package (v2.0.1)

teunbrand
  • 33,645
  • 4
  • 37
  • 63