project-gen3sis / R-package

Repository of the R-packageGen3sis
https://project-gen3sis.github.io/R-package/
GNU General Public License v3.0
29 stars 9 forks source link

plot_richness #37

Closed alexskeels closed 4 years ago

alexskeels commented 4 years ago

plot_richness causes gen3sis to crash when called in the observer function when all species have gone extinct.

plot_richness(species, landscape) Error in (mult * length(col)):1 : NA/NaN argument In addition: Warning message: In x[] <- col[x] : number of items to replace is not a multiple of replacement length

The problem is there is no color in the richness palette for values of 0

max(richness) [1] 0 color_richness(max(richness, na.rm=TRUE)) [1] character(0) color_richness(1) [1] "#440154"

This problem also means colours on a richness plot cannot distinguish between cells with 1 species and cells with 2 species.