我是从另一个论坛(https://www.biostars.org/p/268514/#268559)转贴而来,那里有一些有用的评论,但我仍然对ggplot2的输出感到困惑。
我试图在圆形上获得简单的黑色轮廓,但我的代码现在给出了随机颜色,并似乎忽略了我的scale_colour_manual(values = cols)参数。当我运行以下代码时:
我使用定义的颜色板得到了一个漂亮的图表:
调色板仍然存在。
我试图在圆形上获得简单的黑色轮廓,但我的代码现在给出了随机颜色,并似乎忽略了我的scale_colour_manual(values = cols)参数。当我运行以下代码时:
# creating color palette
> cols <- c("red" = "red", "orange" = "orange", "nonsignificant" = "darkgrey", "Increased" = "#00B2FF", "Decreased" = "#00B2FF")
# Make a basic ggplot2 object
> vol <- ggplot(data, aes(x = lfc, y = pval, color = color, labels=gene))
# inserting mnaual colors as per color pallette with term "scale_colour_manual(values = cols)" below
> vol +
ggtitle(label = "Volcano Plot", subtitle = "Colored by fold-change direction") +
geom_point(size = 2.5, alpha = 1, na.rm = T) +
scale_colour_manual(values = cols) +
theme_bw(base_size = 14) +
theme(legend.position = "right") +
xlab(expression(log[2]("VitD" / "Carrier"))) +
ylab(expression(-log[10]("FDR"))) + # Change Y-Axis label
geom_hline(yintercept = 1, colour="#990000", linetype="dashed") + geom_vline(xintercept = 0.586, colour="#990000", linetype="dashed") + geom_vline(xintercept = -0.586, colour="#990000", linetype="dashed") +
scale_y_continuous(trans = "log1p")
我使用定义的颜色板得到了一个漂亮的图表:
ggplot
对象。> vol <- ggplot(data, aes(x = lfc, y = pval, fill = color, labels=gene))
我在"geom_point"参数中添加了"shape = 21, colour = "black"":
> vol +
ggtitle(label = "Volcano Plot", subtitle = "Colored by fold-change direction") +
geom_point(size = 2.5, alpha = 1, na.rm = T, shape = 21, colour = "black") +
scale_colour_manual(values = cols) +
theme_bw(base_size = 14) +
theme(legend.position = "right") +
xlab(expression(log[2]("VitD" / "Carrier"))) +
ylab(expression(-log[10]("FDR"))) + l
geom_hline(yintercept = 1, colour="#990000", linetype="dashed") + geom_vline(xintercept = 0.586, colour="#990000", linetype="dashed") + geom_vline(xintercept = -0.586, colour="#990000", linetype="dashed") +
scale_y_continuous(trans = "log1p")
突然间我有了一个情节,似乎是随机选择了5种颜色; 如果我打印这些颜色:
print(cols)
red orange nonsignificant Increased Decreased
"red" "orange" "darkgrey" "#00B2FF" "#00B2FF"
调色板仍然存在。