plot_violinPDFs: Plot the pdfs as violins

View source: R/plot.violinPDFS.R

plot_violinPDFsR Documentation

Plot the pdfs as violins

Description

Plot the pdfs as violins

Usage

plot_violinPDFs(
  x,
  climate = x$parameters$climate[1],
  taxanames = x$input$taxa.name,
  col = viridis::viridis(20),
  ylim = range(x$modelling$xrange[[climate]]),
  save = FALSE,
  filename = "violinPDFs.pdf",
  width = 7.48,
  height = 5,
  as.png = FALSE,
  png.res = 300
)

Arguments

x

A crestObj generated by either the crest.calibrate, crest.reconstruct or crest functions.

climate

Climate variables to be used to generate the plot. By default all the variables are included.

taxanames

A list of taxa to use for the plot (default is all the recorded taxa).

col

A vector of colours that will be linearly interpolated to give a unique colour to each taxon.

ylim

The climate range to plot the pdfs on. Default is the full range used to fit the pdfs (x$modelling$xrange)

save

A boolean to indicate if the diagram should be saved as a pdf file. Default is FALSE.

filename

An absolute or relative path that indicates where the diagram should be saved. Also used to specify the name of the file. Default: the file is saved in the working directory under the name 'violinPDFs.pdf'.

width

The width of the output file in inches (default 7.48in ~ 19cm).

height

The height of the output file in inches (default 3in ~ 7.6cm per variables).

as.png

A boolean to indicate if the output should be saved as a png. Default is FALSE and the figure is saved as a pdf file.

png.res

The resolution of the png file (default 300 pixels per inch).

Value

A table with the climate tolerances of all the taxa

Examples

## Not run: 
  data(crest_ex_pse)
  data(crest_ex_selection)
  reconstr <- crest.get_modern_data(
    pse = crest_ex_pse, taxaType = 0,
    climate = c("bio1", "bio12"),
    selectedTaxa = crest_ex_selection, dbname = "crest_example"
  )
  reconstr <- crest.calibrate(reconstr,
    geoWeighting = TRUE, climateSpaceWeighting = TRUE,
    bin_width = c(2, 20), shape = c("normal", "lognormal")
  )

## End(Not run)
## example using pre-saved reconstruction obtained with the previous command.
data(reconstr)
ranges <- plot_violinPDFs(reconstr, save=FALSE, ylim=c(5,35),
                taxanames=c(reconstr$inputs$taxa.name[c(2,4,5,1)], 'Taxon'),
                col=c('darkblue', 'firebrick3'))
lapply(ranges, head)


crestr documentation built on Jan. 6, 2023, 5:23 p.m.