I have searched a lot for a solution to this problem, and only found this similar question where the solution for a similar problem is described but seems to be too complicated.
ggplot2 heatmaps: using different gradients for categories
I would like to know if there is another EASIER solution for a similar problem.
I have a simple dataframe:
,X,Likelihood,Impact
1,A,Almost Certain,Catastrophic
2,B,Likely,Major
3,C,Possible,Moderate
4,D,Likely,Minor
5,E,Rare,Incidental
6,F,Unlikely,Incidental
7,G,Unlikely,Incidental
From which I want to build a heatmap. This is straightforward using:
ggplot(df, aes(Impact, Likelihood)) +
geom_tile(aes(fill = X), colour = "white") +
geom_text(aes(label = X))
However, the color are distributed randomly, what I want to have is a custom color for each pair of (Impact, Likelihood). E.g., the tile for the pair (Almost Certain, Catastrophic) should be colored in 'red'.
How can I achieve this?