0

So I have been using the 'letsR' package to build range maps for a group of bird species in Southeast Asia.

Does anyone know if it is possible to adjust or scale the legend? I have largely used this blog, to help build the maps https://rmacroecology.netlify.com/2018/01/23/a-guide-to-transform-species-shapefiles-into-a-presence-absence-matrix-based-on-a-user-defined-grid-system/

I have checked everywhere in the vignette and can't see this anywhere. I have also emailed the people who created the package, to no success.

What I would like to do is either scale all the legends relative to the map with the most species, i.e. 60 species (highest recorded) = 100. At the minute, all these red areas look equal. Is there a way to possible gradate the colours, so one red is paler for example, for areas of species overlap in maps containing less species ranges? Ulimately, the scale would be standardized to 60

Plots

Employed Russian
  • 199,314
  • 34
  • 295
  • 362

1 Answers1

0

I took a quick look at their code on Github. I do think you'd have to rebuild a function to plot a presence-absence matrix, but it doesn't look that bad - especially if you follow their example closely. The plotting code they have is pretty short, and easy to replicate.

The relevant piece is here in their plotting code: https://github.com/macroecology/letsR/blob/master/R/plot_PresenceAbsence.R#L44-L53

    # Getting values  
    v <- values(x$Rich)
    c <- max(v, na.rm = TRUE)

    # Set zero to NA
    v[(v == 0)] <- NA
    values(x$Rich) <- v

    # Plot, add one and remove the first to not be white.
    plot(x$Rich, col = colfunc(c + 1)[-1], ...)  

They're setting the variable c to the maximum value per plot, but you could set it directly to whatever value you thought made a consistent maximum. Replicating their plotting function, but replacing the assignment of c in that second line might get you what you need to standardize scales.

ravic_
  • 1,731
  • 9
  • 13
  • So @ravic_ I used this link here... https://stackoverflow.com/questions/13353213/gradient-of-n-colors-ranging-from-color-1-and-color-2 to help me in creating the new colour function. – user241508 Nov 24 '19 at 22:49