Znalazłem dość zagmatwaną funkcję w ggplot podczas próbowania przypisywania segmentów w skali log10. Poniższy kod tworzy poniższy wykres:Adnotacja segmentu w skali log10 działa inaczej dla końca i początku segmentu?
library(ggplot2)
dat <- data.frame(x = x <- 1:1000, y = log(x))
ggplot(dat, aes(x = x, y = y)) +
geom_line(size = 2) + scale_x_log10() +
annotate("segment", x = 0, xend = log10(100), y = log(100), yend = log(100), linetype = 2) +
annotate("segment", x = log10(100), xend = log10(100), y = 0, yend = log(100), linetype = 2)
niniejsza jest co jestem po:
ggplot(dat, aes(x = x, y = y)) +
geom_line(size = 2) + scale_x_log10() +
annotate("segment", x = 0, xend = log10(100), y = log(100), yend = log(100), linetype = 2) +
annotate("segment", x = 100, xend = log10(100), y = 0, yend = log(100), linetype = 2)
Innymi słowy, muszę log10 przekształcić punkt końcowy segmentu na osi X, ale nie na początku. Czy to zachowanie ma logiczne wytłumaczenie? Rozumiem, że aes()
does the transformations ... ale w tym przypadku transformacje na osi X powinny być jednolite (dobrze, log10), prawda?
pracuję nad:
R version 3.0.0 (2013-04-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
ggplot2_0.9.3.1