How do I determine the default color palette used by function ggiNEXT in the package iNEXT?

348 Views Asked by At

I am trying to match the aesthetics of ggiNEXT objects in a series of manually generated ggplot2 figures. Sample figure is below, where colors of lines and 95% confidence intervals are those chosen by default by function ggiNEXT (code taken directly from function help):

library(iNEXT)
library(ggplot2)
z <- iNEXT(spider, q=c(0,1,2), datatype="abundance")
ggiNEXT(z, facet.var="Assemblage", color.var="Order.q")

Sample ggiNEXT plot

I want to determine what colors are used by default for lines and 95% confidence intervals - how can I figure this out?

1

There are 1 best solutions below

0
overcup On BEST ANSWER

Function ggplot_build() in package ggplot2 can be used to extract colors.

> palette_extract <- ggplot_build( ggiNEXT(z, facet.var="Assemblage", color.var="Order.q") )
> as.vector(unique(palette_extract$data[[1]][1]))
$colour
[1] "#D55E00" "#0072B2" "#CC79A7"