datascience-mobi-2023 / topic05_team03

0 stars 0 forks source link

Plot outputs in Rmarkdown #9

Closed aluisascosta closed 1 year ago

aluisascosta commented 1 year ago

Hi Eran,

To plot side-by-side refer to the RMarkdown guide here: https://bookdown.org/yihui/rmarkdown-cookbook/figures-side.html All you have to do is "hold" the figures and make sure that each figure is only plotted on a percentage of the page. For 3, use out.width="33%".

About overlaying the plots, I have tried this inside one chunk and it worked as intended in printing (replace accordingly):

plot(x = t1$conc, y = t1$prism, col = "blue");abline(lm(t1$prism ~ t1$conc), col = "blue")
points(x = t2$conc, y = t2$prism, col = "orange");abline(lm(t2$prism ~ t2$conc), col = "orange")
points(x = t3$conc, y = t3$prism, col = "green");abline(lm(t3$prism ~ t3$conc), col = "green")

They are directly plotted over each other: image