# Function to create curly braces # v0.1 # # x, y center of where to put the braces # range is the width # position: 1 vertical, 2 horizontal # direction: 1 left/down, 2 right/up # curly.brace <- function(x, y, range, height, pos = 1, direction = 1, adj=1, lwd=1 ) { a=c(1,2,3,48,50) # set flexion point for spline b=c(0,.2,.28,.7,.8) # set depth for spline flexion point b=b*height # height of the brace curve = spline(a, b, n = 50, method = "natural")$y / 2 curve = c(curve,rev(curve))/adj a_sequence = rep(x,100) b_sequence = seq(y-range/2,y+range/2,length=100) # direction if(direction==1) a_sequence = a_sequence+curve if(direction==2) a_sequence = a_sequence-curve # pos if(pos==1) lines(a_sequence,b_sequence, lwd=lwd) # vertical if(pos==2) lines(b_sequence,a_sequence, lwd=lwd) # horizontal }