Changing colors and adding labels to a nestedtemp() plot using the vegan package

37 Views Asked by At

I used the R package vegan to check for nestedness in my dataset:

bc_rp <- read.csv("BC_RPc.csv", na.strings = c("","NA"), header=TRUE, check.names = FALSE)

bc_rp

bc <- data.frame(
  cell_layer = c("H", "B", "A", "G", "O"),
  Np = c(0, 1, 1, 0, 0),
  Pn = c(1, 1, 0, 0, 1),
  Npn = c(0, 1, 0, 0, 0),
  Npnp = c(0, 1, 0, 0, 0),
  Pnp = c(1, 0, 0, 0, 0),
  Pnpn = c(0, 1, 0, 0, 0)
)


# Renamed the columns to be easier to manipulate and have no special characters
# colnames(hc) <-c('species', 'a','b','c','d','e','f','g')

# Transpose the rows and columns in data. 
bc_t <-t(bc)

out_bc_t <- nestedtemp(bc_t)
out_bc_t
#nestedness temperature: 10.24168 
#with matrix fill 0.4 

plot(out_bc_t, kind="incid")

And this code works as expected to produce a nestedness temperature and a plot.

nestedness temperature: 10.24168 with matrix fill 0.4 Nestedness Plot

However, I, wish I could change the color of the plot to be something other than Red, and add labels for each cell type, and for the categories(np, pn, etc) How would I do this?

1

There are 1 best solutions below

2
Jari Oksanen On

A good starting point is the documentation of the function (try ?nestedtemp). The plot function for the nestedtemp seems to have argument col that can be used to set the colours, and names that defaults to names = FALSE, but setting TRUE would add names (according to documentation at least – I didn't try). If these do not help you, please ask a more detailed question.