ggplot2 - Diagonal grading of background color of ggplot graph in R -


i looking graph in following style, fading background. more specifically, hope diagonal fading

desired graph

i have made graph so:

ggplot(data) +   aes(x=data$log.avg, y=data$cov) +   geom_point(alpha = 0.3) +   ggtitle("oversigt on 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")  

this basic approach helped me similar problem.

## create diag gradient background ## create df supply background geom_tile df <- expand.grid(x=-100:100, y=-100:100)     # dataframe combinations  ## plot ggplot(df, aes(x, y, fill=x+y)) +      # map fill sum of x & y   geom_tile(alpha = 0.75) +      # let grid show through bit   scale_fill_gradient(low='light blue', high='steelblue4')     # choose colors 

result:enter image description here

consider following:

`aes(x, y, fill=x+y)` # darkest in top right corner `aes(x, y, fill=y-x)` # darkest in top left corner 

to used in combo switches high & low arguments in scale_fill_gradient


Comments

Popular posts from this blog

php - Auto increment employee ID -

php - isset function not working properly -

python - Evaluating the next line in a For Loop while in the current iteration -