Browse Source

updated R plotting tutorial script

master
chassenr 1 year ago
parent
commit
6485d2f244
  1. 12
      R_plotting_2022/R_plotting_script.R

12
R_plotting_2022/R_plotting_script.R

@ -175,7 +175,7 @@ legend(
# define what should be plotted
myplot <- function() {
plot(x, y, pch = 16, col = "red", axes = F)
plot(x, y, pch = 16, col = "red", axes = F)
abline(mod, col = "red")
polygon(
c(x, rev(x)),
@ -191,7 +191,14 @@ subplot(
myplot(),
x = c(-0.04, 0.3), # x coordinates for lower left and upper right corner of subplot
y = c(-0.58, -0.2), # y coordinates for lower left and upper right corner of subplot
pars = list(mar = c(0, 0, 0, 0), ann = F) # list of plotting paramters for subplot
pars = list(mar = c(0, 0, 0, 0), ann = F) # list of plotting parameters for subplot
)
# scale based on user coordinates
subplot(
myplot(),
x = c(par("usr")[1], par("usr")[1] + (par("usr")[2] - par("usr")[1]) * 0.3),
y = c(par("usr")[3], par("usr")[3] + (par("usr")[4] - par("usr")[3]) * 0.3),
pars = list(mar = c(0, 0, 0, 0), ann = F)
)
# draw border around subplot
@ -301,6 +308,7 @@ for(i in 1:6) {
# to save as pdf, run this before starting plot
pdf("figure.pdf", width = 7, height = 9) # device dimensions are in inches (A4)
# your plottin code
# close with
dev.off()
# multiple plots can be added to a multi-page pdf with the argument 'onefile = T'

Loading…
Cancel
Save