if(interactive()){
p <- l_plot()
l <- l_layer_rectangles(
p,
x = list(c(0,1), c(1,2), c(2,3), c(5,6)),
y = list(c(0,1), c(1,2), c(0,1), c(3,4)),
color = c('red', 'blue', 'green', 'orange'),
linecolor = "black"
)
l_scaleto_world(p)
l_info_states(l)
# Set groups
pp <- l_plot(x = c(0,1,1,2,2,3,5,6),
y = c(0,1,1,2,0,1,3,4))
# x and y are inherited from pp
ll <- l_layer_rectangles(
pp,
group = rep(1:4, each = 2),
color = c('red', 'blue', 'green', 'orange'),
linecolor = "black"
)
l_scaleto_world(pp)
}
Run the code above in your browser using DataLab