rggplot2ggcorrplot

Customize ggcorrplot legend


I am working with a connectivity matrix of a network with positive values only and I want to display it before and after a threshold being applied. I´ve already used corrplot library, which allows plenty of changes in legend and colors but I decided to use ggcorrplot because corrplot figures get changed when I try to put them together in a graph trough grid.arrange. The main problem with ggcorrplot is that I haven´t been able to change legend values to be only between 0 and 1. My code is the next

    library(ggcorrplot)
    library(ggplot)

    ggcorrplot(prom_orig_sub, legend.title = "Coherencia")

enter image description here

Could you suggest some solution to change legend values? Thak you so much.


Solution

  • Try overwriting the fill with scale_fill_gradient. It would likely alter the default colour scheme for ggcorrplot though.

    ggcorrplot(prom_orig_sub, legend.title = "Coherencia") + 
         scale_fill_gradient2(breaks=c(0, 1), limit=c(0, 1))