Closed juandemedel closed 2 years ago
Hi @juandemedel, thanks for opening this issue! I addressed the part about thin lines in legend in https://github.com/rmaia/pavo/commit/3e5c490e68d032edb49b1ffd4fd435de6f64feed. The lines in the legend will now have the same width as the lines in the plot, as determined by the lwd
argument.
#> Welcome to pavo 2! Take a look at the latest features (and update your bibliography) in our recent publication: Maia R., Gruson H., Endler J. A., White T. E. (2019) pavo 2: new tools for the spectral and spatial analysis of colour in R. Methods in Ecology and Evolution, 10, 1097-1107.
# Load reflectance data
data(sicalis)
# Create grouping variable based on spec names
bysic <- gsub("^ind[0-9].", "", names(sicalis)[-1])
aggplot(sicalis, bysic, legend = TRUE)
aggplot(sicalis, bysic, legend = TRUE, lwd = 3)
Created on 2022-06-19 by the reprex package (v2.0.1.9000)
library(pavo)
#> Welcome to pavo 2! Take a look at the latest features (and update your bibliography) in our recent publication: Maia R., Gruson H., Endler J. A., White T. E. (2019) pavo 2: new tools for the spectral and spatial analysis of colour in R. Methods in Ecology and Evolution, 10, 1097-1107.
# Load reflectance data
data(sicalis)
# Create grouping variable based on spec names
bysic <- gsub("^ind[0-9].", "", names(sicalis)[-1])
aggplot(sicalis, bysic, legend = TRUE)
aggplot(sicalis, bysic, legend = TRUE, lwd = 3)
Created on 2022-06-19 by the reprex package (v2.0.1.9000)
For the second part, about custom placement, I cannot think about a great solution for now. You best bet at the moment is probably to create the legend yourself manually. Here is an example of how you might do it:
library(pavo)
#> Welcome to pavo 2! Take a look at the latest features (and update your bibliography) in our recent publication: Maia R., Gruson H., Endler J. A., White T. E. (2019) pavo 2: new tools for the spectral and spatial analysis of colour in R. Methods in Ecology and Evolution, 10, 1097-1107.
# Load reflectance data
data(sicalis)
# Create grouping variable based on spec names
bysic <- gsub("^ind[0-9].", "", names(sicalis)[-1])
# Set custom parameters
my_cols <- c(
"#E41A1C", "#377EB8", "#4DAF4A"
)
my_lwd <- 3
aggplot(sicalis, bysic, lcol = my_cols, lwd = my_lwd)
# Create custom legend:
# The first argument can be a keyword like "bottomright", "bottom",
# "bottomleft", "left", "topleft", "top", "topright", "right" and "center", or
# x, y coordinates. See ?legend for more information
legend("bottomright", bty = "n", legend = unique(bysic), col = my_cols, lty = 1, lwd = my_lwd)
Created on 2022-06-19 by the reprex package (v2.0.1.9000)
Please let us know if this helps!
Thank you so much.
Hello dear community @thomased, @Bisaloo. I've been working on an aggplot legend. This legend shows several lines. However, those lines are as thin as they can not be perceived easily in a plot. Besides, I would like to change the legend size and placement in the plot. Would you please give me some advice to fix it?