Tt.spectra: Plot spectra for EDS analysis

View source: R/Ttspectra.R

Tt.spectraR Documentation

Plot spectra for EDS analysis

Description

The function uses basic R plot for plotting spectra. However, if elements.list is provided, it will provide labels for the elements, based on the energy (KeV) table of the elements for EDS analysis.

Usage

Tt.spectra(energy, counts, elements.list = NULL, lab.size = 1,
  y.lim = c(0, max(counts, na.rm = T)), x.lim = c(0, max(energy, na.rm
  = T)), as.ggplot = TRUE)

Arguments

energy

vector containing the values for the x axe. Typically in KeV for EDS analysis

counts

vector containing the values for the y axe

elements.list

a vector containing the simbol of the elements to be displayed in the graphic

lab.size

size of the labels. Note that this size is considerably different for ggplot2 and basic R

y.lim

vector containing limits for y axe

x.lim

vector containing limits for x axe

as.ggplot

creates the plot using 'ggplot2' and 'scales' packages. If false, it will use base R packages

Value

spectra plot

Examples

Tt.spectra(spectrum$Energy, spectrum$Counts,elements.list=c('Pb','Zn','P'), y.lim=c(0,4000), x.lim=c(0,11), as.ggplot=F) # Simple plot with personilised limits
Tt.spectra(spectrum$Energy, spectrum$Counts,elements.list=c('Ca'),as.ggplot=F) # When there is overlap, as Ca and Sb, is best to add second element manually
text(3.5, 500, 'Prueba', cex = 0.8)
Tt.spectra(spectrum$Energy, spectrum$Counts,elements.list=c('Ca')) # However this has been fixed using 'ggplot2'

teoten108/kgv documentation built on Sept. 22, 2022, 12:54 a.m.