I've plotted a heat-map like this:
ggplot(test, aes(start1, start2)) +
geom_tile(aes(fill = logFC), colour = "gray", size=0.05) +
scale_fill_gradientn(colours=c("#0000FF","white","#FF0000"), na.value="#DAD7D3")
This plots the upper triangle of a heatmap. What i'd like to plot is the very same triangle, but having the hypotenuse as the x-axis
.
How would I do that?
Edit: Added reproducible example
library(ggplot2)
# dummy data
df1 <- mtcars[, c("gear","carb", "mpg")]
# normal tile plot
gg1 <- ggplot(df1, aes(gear, carb, fill = mpg)) +
geom_tile() +
xlim(c(1, 10)) +
ylim(c(1, 10)) +
theme_void() +
theme(legend.position = "none")
Expected output (rotated manually):
Related post using base plot image()
:
Visualising and rotating a matrix
Possible solution example code is in LDheatmap package using grid
.
Using this solution gets the output clipped at the bottom, so workaround would be to add extra plot margins then use
grid::viewport()
to rotate: