I'm trying to visualize a Bayesian network, and due to the density of lines, I decided to use a luminosity gradient to visualize direction of an edge (dark -> light). However, because of this, I had to manually define colors in a geom_path()
statement, and use scale_fill_identity()
instead of a scale_fill_gradient()
that I would normally use. My current graph looks like this:
What I want to do is add a gradient scale that goes from blue to yellow with user-defined values, so that someone can look at a legend and tell what the weights of all of the links are (they're all unitless). The saturations and luminosities are all different from the original colors, but the hues are the same.
Edit: Here is an example you can work with:
ggplot(data.frame(x=1),aes(x=x,y=1,color='red',fill='blue'))+
scale_color_identity()+scale_fill_identity()+geom_bar(stat='identity')
How does one insert an arbitrary color gradient scale onto this?
Edit 2: I found a roundabout way of doing this via manual insertion of legends from other plots: Control over legends of multiple layer plot in ggplot2
Are there any less hacky ways of doing this?