Hi, I use the following code to get the heatmap (figureA):
My code:
Figure A
However, I don't quite like the color (scale color and color bar). How could I modify the color as the Figure B (only care about the colors).
Figure B
Thank you!
Hi, I use the following code to get the heatmap (figureA):
My code:
Figure A
However, I don't quite like the color (scale color and color bar). How could I modify the color as the Figure B (only care about the colors).
Figure B
Thank you!
You can use scale_fill_gradient2()
instead of scale_fill_gradient()
to have a few more arguments to customize. In particular by setting a mid
color or moving the midpoint
to a particular numeric value, you can adjust the gradient to your liking.
scale_fill_gradient2(
...,
low = "white",
mid = "red50",
high = "red",
midpoint = 0.02,
space = "Lab",
na.value = "grey50",
guide = "colourbar",
aesthetics = "fill"
)
You can also choose your desired colour with various online tools (search for "Hex colour picker"), if you need an exact matching colour to some template.
To change the appearance of the legend, e.g. make the bar smaller you can use the legend options of theme()
, e.g. legend.key=element_rect()
and legend.key.text=element_text()
. Like so, you can for example highlight the breaks in black or make the legend width smaller.
I hope this helped. Best Matthias
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Not sure if I understood the problem - do you want a different "red" tonality? Here you can find the different colors in R. Just replace the "#EA3323" by your color of interest.
Thank you! The R colors cheat-sheet is wonderful!