Plotting gl.report.diversity with discrete pop names (1, 2, 3...)

7 views
Skip to first unread message

Matthew Holen

unread,
Jan 12, 2026, 6:11:38 PM (10 days ago) Jan 12
to dartR
Hello,

After completing DAPC, individuals were assigned to their clusters (1-9). With gl.report.diversity I'm running into the issue of plotting and get an error of:
Error in `scale_fill_manual()`: ! Continuous value supplied to a discrete scale. Example values: 1, 2, 3, 4, and 5. Run `rlang::last_trace()` to see where the error occurred.

 Any workaround for this? I tried plot.colors.pop= my own palette but that didn't work either. 

Thank you,
Matt

Jose Luis Mijangos

unread,
Jan 12, 2026, 10:22:14 PM (10 days ago) Jan 12
to dartR
Hi Matt,

Thanks for sending through the subset of your dataset, that made it much easier to dig into the issue.

The problem turned out to be related to using numeric values as population names. I’ve now fixed this bug, and the fix is available in the development version of dartR.base.

Below are the steps to install the updated version and rerun the analysis. Please let me know if anything still looks odd or if you run into any issues.

PS we are organising a dartR workshop next March at Kioloa (see link below) in case you would be interested. It would be also great if you could share the news with people that might be interested.

https://cba.anu.edu.au/news-events/events/dartrverse

Cheers,
Luis

# 1. Clean your environment
# Menu > Session > Clean Workspace
# 2. Restart your R session
# Menu > Session > Restart R
# 3. Install the development version of dartR.base
devtools::install_github("green-striped-gecko/dartR.base@dev")

library(dartRverse)

impute <- readRDS("test.rds")

col2 <- c(
  "#6ccafc", "#ff7f00", "#6a3d9a", "#66d932", "#33a02c",
  "#fb9a99", "#e31a1c", "#00d2e0", "#cf70ff", "#1f78b4", "maroon"
)

diversity <- gl.report.diversity(impute, plot.colors.pop = col2)
Reply all
Reply to author
Forward
0 new messages