相关疑难解决方法(0)

stat_function和legends:使用映射到不同变量的两个单独颜色图例创建绘图

我想在一个图像中使用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)

r ggplot2

8
推荐指数
1
解决办法
1206
查看次数

标签 统计

ggplot2 ×1

r ×1