如果可能的话,我只希望在窗口中心绘制颜色条,就像这样:
一个无法删除点,轴和背景的示例。
library("ggplot2")
library("viridis")
df <- data.frame(x = c(1,2,3,4,5,6), y = c(7,4,9,2,6,7))
ggplot(data = df, aes(x = x, y = y, colour = y)) +
geom_point() +
scale_color_viridis()
1 个答案:
答案 0 :(得分:1)
ggpubr
软件包具有满足此需求的功能。
df <- data.frame(x = c(1,2,3,4,5,6), y = c(7,4,9,2,6,7))
p <- ggplot(data = df, aes(x = x, y = y, colour = y)) +
geom_point() +
scale_color_viridis() +
theme_minimal()
# ggpubr does this for you
library(ggpubr)
leg <- get_legend(p)
as_ggplot(leg)