1
我有R中的下面的代码是从here改性,其绘出一个交叉表:可视化与R中的曲线交叉的表 - 改变颜色
#load ggplot2
library(ggplot2)
# Set up the vectors
xaxis <- c("A", "B")
yaxis <- c("A","B")
# Create the data frame
df <- expand.grid(xaxis, yaxis)
df$value <- c(120,5,30,200)
#Plot the Data
g <- <- ggplot(df, aes(Var1, Var2)) + geom_point(aes(size = value), colour = "lightblue") + theme_bw() + xlab("") + ylab("")
g + scale_size_continuous(range=c(10,30)) + geom_text(aes(label = value))
它产生正确的数字,这是很大的,但我希望自定义颜色的四个点,理想情况下,左上角和右下角都是一种颜色,右上角和左下角是另一种颜色。
我曾尝试使用:
+ scale_color_manual(values=c("blue","red","blue","red"))
,但似乎并没有工作。有任何想法吗?
这给出了两个独立的传说 – PoGibas