# minimal example
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
box()
leg(type = "prop", val = c(10, 50, 100), pos = "topleft")
leg(type = "choro", val = c(10, 20, 30, 40, 50), pos = "bottomleft")
leg(type = "typo", val = c("A", "B", "C"), pos = "top")
leg(type = "symb", val = c("A", "B", "C"), pos = "topright")
leg(type = "prop_line", val = c(5, 50, 100), pos = "bottom", lwd = 20)
leg(
type = "grad_line", val = c(1, 4, 10, 15), pos = "bottomright",
lwd = c(1, 5, 10)
)
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg(type = "prop", val = c(10, 50, 100), pos = "topleft", horiz = TRUE)
leg(type = "choro", val = c(10, 20, 30, 40, 50), pos = "left", horiz = TRUE)
leg(
type = "cont", val = c(10, 20, 30, 40, 50), pos = "bottomleft",
horiz = TRUE
)
leg(
type = "cont", val = c(10, 20, 30, 40, 50), pos = "topright",
horiz = FALSE
)
set.seed(46)
leg(
type = "histo", val = hist(rnorm(1000), breaks = 5, plot = FALSE),
pos = "bottomright"
)
box()
# full example
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg(
type = "prop",
val = c(5, 100),
pos = "top",
inches = .4,
symbol = "circle",
col = "#940000",
lwd = 1,
border = "#9494ff",
val_rnd = 1,
self_adjust = TRUE,
title = "Proportional Symbols",
title_cex = 1,
val_cex = .8,
bg = "grey10",
fg = "yellow",
frame = TRUE
)
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg(
type = "choro",
alpha = 1,
val = c(10, 20, 30, 40, 50),
pos = "top",
pal = c("#7F000D", "#B56C6F", "#DBBABB", "#F1F1F1"),
val_rnd = 2,
col_na = "grey",
no_data = TRUE,
no_data_txt = "No data",
box_border = "cornsilk",
box_cex = c(2, 1),
title = "Choropleth (sequential)"
)
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg(
type = "typo",
val = c("A", "B", "C"),
pos = "top",
pal = "Dynamic",
col_na = "grey",
no_data = TRUE,
no_data_txt = "No data",
box_cex = c(1.2, 1),
title = "Typology (categories)"
)
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg(
type = "symb",
val = c("A", "B", "C"),
pos = "top",
pch = 21:23,
cex = c(4, 4, 2),
pal = "Inferno",
lwd = 2,
border = "red",
col_na = "grey",
pch_na = 3,
cex_na = 1,
no_data = TRUE,
no_data_txt = "No data",
title = "Symbols"
)
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg(
type = "cont",
val = c(1, 2, 3, 4, 5),
pos = "top",
pal = "Inferno",
alpha = .7,
val_rnd = 2,
horiz = TRUE,
box_cex = c(2, 1),
title = "Continuous"
)
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg(
type = "prop_line",
val = c(54, 505, 1025),
pos = "top",
lwd = 15,
col = "green",
val_rnd = -1,
box_cex = c(2, .5),
title = "Proportional Lines",
bg = "black",
fg = "white",
frame = TRUE
)
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg(
type = "grad_line",
val = c(1.25, 4.07, 10.001, 15.071),
pos = "top",
lwd = c(1, 7, 15),
col = "#C130ff",
val_rnd = 3,
box_cex = c(2, 1),
title = "Graduated Lines"
)
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
set.seed(46)
x <- rnorm(10000) * 1000
val <- hist(x, breaks = quantile(x, 0:10/10), plot = FALSE)
leg(
type = "histo",
alpha = 1,
val = val,
pos = "top",
pal = "Teal",
val_rnd = 0,
val_big = " ",
box_border = "cornsilk",
box_cex = c(1, 2),
title = "Histogram"
)
# Positions
plot.new()
plot.window(xlim = c(0, 1), ylim = c(0, 1), asp = 1)
leg(
type = "prop", val = c(10, 60, 100), pos = "bottomleft", adj = c(0, 4),
title = "adj = c(0, 4)", frame = TRUE
)
leg(
type = "choro", val = c(10, 50, 100), pos = "bottomright",
adj = c(0, 8), title = "adj = c(0, 8)", frame = TRUE
)
leg(
type = "prop", val = c(10, 50, 100), pos = "topleft",
adj = c(0, -8), title = "adj = c(0, -8)"
)
box()
mtext(
text = "A text on 1 line", side = 1, adj = .01,
line = -1, cex = 1
)
mtext(
text = "A text\non 2 lines", side = 1, adj = .99,
line = -1, cex = 1
)
mtext(
text = "A large text on 1 line", side = 3, adj = .01,
line = -2, cex = 2
)
Run the code above in your browser using DataLab