I want to make a plot which I want the figure height to be exactly the 1.5 times of the figure width. Also, I want the x-axis and y-axis use the same unit. Here is my code of 3 figures on one pdf.
# met1 is a dataframe
a = 1.1*max(met1$x)
b = (a*1.5)
canvas_height = 14
canvas_width = 30
p1 <- ggplot(met1, aes(x = x, y = y)) +
geom_point(aes(colour = nCount_spatial),size=0.8) +
scale_x_continuous(labels = label_number(suffix = "K", scale = 1e-3), limits = c(0,a), expand = c(0,0))+
scale_y_continuous(labels = label_number(suffix = "K", scale = 1e-3),limits = c(0, b), expand = c(0,0))+
scale_color_gradient(low = "lightblue", high = "darkblue",name='MID',
labels=label_number(suffix = "K", scale = 1e-3)) +
labs(title='MolecularID heatmap')+
theme(axis.title = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
axis.text=element_text(size=12))
pdf(file = paste(out_path,"/Plot.pdf', sep = ''), w = canvas_width, h = canvas_height)
p1 + p1 + p1
dev.off()
Here is the plot I got:
You will see each figure height is near 1.5 times of the figure width. However, the physical length from 0 to 3k on x-axis and on y-axis are actually not the same.
How do I make the the physical length from 0 to 3k on x-axis and on y-axis are the same, while still maintain the figure height is 1.5 times of the figure width in each figure? If anyone can share their idea and codes how to generate the plot, that will be really great.
Appreciate your help in advance.
Best,
LC