Yes! There is a trans
argument to scale_fill_gradient
, which I had missed before. With that we can get a solution with appropriate legend and color scale, and nice concise syntax. Using p
from the question and my_breaks = c(2, 10, 50, 250, 1250, 6000)
:
p + scale_fill_gradient(name = "count", trans = "log",
breaks = my_breaks, labels = my_breaks)
My other answer is best used for more complicated functions of the data. Hadley’s comment encouraged me to find this answer in the examples at the bottom of ?scale_gradient
.