我有以下示例数据:
library(ggplot2)
count <- c(100,150,112)
cat <- c("A", "B", "C")
sentiment <- c(-0.3, 0.2, 0.8)
duration <- c(5.6, 8.2,5.2)
silence <- c(0.2, 0.05,0.1)
df <- data.frame(count, cat, sentiment, duration, silence)
我使用该数据创建以下气泡图
p6 <- ggplot(df, aes(x = duration, y = silence, size = count, colour = sentiment)) + geom_point()
p7 <- p6 + scale_size_continuous(range = c(5, 8))
p7 + scale_x_continuous(limits = c(2, 10)) + scale_y_continuous(limits = c(0,0.25)) + theme(legend.position="none")
这一切都很好,但问题是我想要从绿色(情感= 1)到红色(情绪= -1)的颜色点。
有关如何做到的任何想法?