我希望以下列风格制作图表,背景渐弱。更具体地说,我希望得到一个对角线渐弱
我已经将图形设为如此:
ggplot(Data) +
aes(x=Data$log.avg, y=Data$CoV) +
geom_point(alpha = 0.3) +
ggtitle("Oversigt over udbetalingskonti") +
geom_text(aes(label=ifelse(Data$log.avg > 1.6 | Data$CoV > 2 &
Data$log.avg > -0.5 , as.character(Data$KT),'')),hjust=-0.2, vjust=-0.2, size=3) +
labs(x="Avg",y="Coefficient of Variation")
答案 0 :(得分:1)
This basic approach帮助我解决了类似的问题。
## create a diag gradient background
## create a df to supply the background to geom_tile
df <- expand.grid(x=-100:100, y=-100:100) # dataframe for all combinations
## plot
ggplot(df, aes(x, y, fill=x+y)) + # map fill to the sum of x & y
geom_tile(alpha = 0.75) + # let the grid show through a bit
scale_fill_gradient(low='light blue', high='steelblue4') # choose your colors
请考虑以下事项:
`aes(x, y, fill=x+y)` # darkest in the top right corner
`aes(x, y, fill=y-x)` # darkest in the top left corner
用于组合切换到high
&amp; low
scale_fill_gradient
个参数