Displaying Isotopic Abundance Percentages with Bar Charts and Pie Charts

[This article was first published on The Chemical Statistician » R programming, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

The Structure of an Atom

An atom consists of a nucleus at the centre and electrons moving around it.  The nucleus contains a mixture of protons and neutrons.  For most purposes in chemistry, the two most important properties about these 3 types of particles are their masses and charges.  In terms of charge, protons are positive, electrons are negative, and neutrons are neutral.  A proton’s mass is roughly the same as a neutron’s mass, but a proton is almost 2,000 times heavier than an electron.

lithium atom

This image shows a lithium atom, which has 3 electrons, 3 protons, and 4 neutrons.  

Source: Wikimedia Commons

What is an Isotope?

A chemical element is defined by the number of protons in the nuclei of its atoms – this is the atomic number.  However, an element can have atoms with different numbers of neutrons in their nuclei, resulting in various “versions” of the element.  An isotope is a variant of an element based on the number of neutrons in its atoms.  The sum of the numbers of protons and neutrons of an atom is the atomic mass number, and the name of an isotope is defined by this number.

Consider chlorine, which has 2 stable isotopes: chlorine-35 and chlorine-37.   Chlorine has 17 protons, so chlorine-35 has 18 neutrons, and chlorine-37 has 20 neutrons.  The natural abundances of these two isotopes are 75.77% and 24.23%, respectively.  Thus, if you take a random sample of elemental chlorine that exists in the universe, you should find that about three-quarters of your sample consists of chlorine-35, while the remaining quarter consists of chlorine-37.

The isotopic abundances of chlorine can be displayed easily in a bar chart or a pie chart.  In R, the relevant functions are barplot() and pie().

chlorine bar chartchlorine pie chart

Source of isotopic abundances: “Chemistry” by Olmstead and Williams, 3rd Edition.  Page 53.

Here is my R code for generating these charts.

##### Displaying Isotopic Abundances with Bar Charts and Pie Charts
##### Script Written by Eric Cai - The Chemical Statistician

### Entering the data and legend vectors
chlorine.isotopes = c('Chlorine-35', 'Chlorine-37')
chlorine.isotopic.abundance = c(0.7577, 0.2423)
chlorine.legend = c('Chlorine-35: 75.77%', 'Chlorine-37: 24.23%')

### Creating the charts

# The plotting functions are "sandwiched" by "png()" and "dev.off" 
# so that PNG images of these charts are automatically sent to my 
# designated folder

png('insert your directory path here/chlorine bar chart.png')
barplot(chlorine.isotopic.abundance, names.arg = chlorine.isotopes, 
main = 'Isotopic Abundance of Chlorine', 
xlab = 'Stable Isotopes of Chlorine', col = c('blue', 'red'), 
ylim = c(0,1), legend = chlorine.legend)

png('insert your directory path here/chlorine pie chart.png')
pie(chlorine.isotopic.abundance, labels = chlorine.legend, 
main = 'Isotopic Abundance of Chlorine', col = c('blue', 'red'))

Filed under: Basic Chemistry, Descriptive Statistics, Plots, R programming Tagged: atomic mass number, atomic number, bar chart, barplot(), categorical variable, chemistry, data, data visualization, descriptive statistics, isotope, neutron, pie chart, pie(), plot, plots, plotting, PNG, proton, R, R programming, statistics

To leave a comment for the author, please follow the link and comment on their blog: The Chemical Statistician » R programming.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)