我想在一个图像中使用ggplot2组合两种不同类型的图.这是我使用的代码:
fun.bar <- function(x, param = 4) {
return(((x + 1) ^ (1 - param)) / (1 - param))
}
plot.foo <- function(df, par = c(1.7, 2:8)) {
require(ggplot2)
require(reshape2)
require(RColorBrewer)
melt.df <- melt(df)
melt.df$ypos <- as.numeric(melt.df$variable)
p <- ggplot(data = melt.df, aes(x = value, y = ypos, colour = variable)) +
geom_point(position = "jitter", alpha = 0.2, size = 2) +
xlim(-1, 1) + ylim(-5, 5) +
guides(colour =
guide_legend("Type", override.aes = list(alpha = 1, size = 4)))
pal …Run Code Online (Sandbox Code Playgroud)