Might be missing something simple here, but my goal is to plot two heatmaps from two separate matrices. The matrices are of different dimensions, but I want each of the individual plotted tiles to be the same physical measurements between the two graphs. The graph size should then be dependent on the matrix dimensions, since the tile size will be constant between the graphs.
Here is an example of two different size matrices and a stripped down version of the graphs I want to make.
mat_lg <- matrix(rexp(20, rate=.1), ncol = 5)
melt(mat_lg) %>%
ggplot(aes(x = Var1, y = Var2, fill = value)) +
geom_tile() +
theme_bw() +
coord_equal()
mat_sm <- matrix(rexp(12, rate = .1), ncol = 3)
melt(mat_sm) %>%
ggplot(aes(x = Var1, y = Var2, fill = value)) +
geom_tile() +
theme_bw() +
coord_equal()
The graph made from mat_lg has smaller tiles...
compared to the tiles in the graph made from mat_sm...
I've played around with the width/height settings in geom_tile, but was unable to achieve my goal. Have also played with grid.arrange as well as facet_wrap settings but to no avail.
My guess is that I need to change the final plot size based on my initial matrix dimension in order to get the tiles with the same physical measurements. Would gladly appreciate any help on this matter!