I am new to ggplot2and relatively new to R. I can take a picture on the graph, and I can take a reverse scale of the y axis, but I don’t know how to do it at the same time. For example:
library(ggplot2)
y=c(1,2,3)
x=c(0,0,0)
d=data.frame(x=x, y=y)
library(png)
library(grid)
img <- readPNG(system.file("img", "Rlogo.png", package="png"))
g <- rasterGrob(img, interpolate=TRUE)
ggplot(d, aes(x, y)) + geom_point()
ggplot(d, aes(x, y)) + geom_point() + scale_y_reverse()
ggplot(d, aes(x, y)) + geom_point() + annotation_custom(g, xmin=.23, xmax=.27, ymin=1.8, ymax=2.2)
ggplot(d, aes(x, y)) + geom_point() + annotation_custom(g, xmin=.23, xmax=.27, ymin=1.8, ymax=2.2) + scale_y_reverse()
ggplot(d, aes(x, y)) + geom_point() + annotation_custom(g, xmin=.23, xmax=.27, ymin=2.2, ymax=1.8) + scale_y_reverse()
I am sure that I am missing something quite simple. Where should I start looking to display my small graphics on the graph in the opposite scale, and also better understand things under the hood?
:
, . , , . , . , , . , , , , .