top of page
frankovski

Cumulative distribution function (CDF) plots of zircon ages with Python


In statistics, a cumulative distribution function (CDF) plot shows the empirical cumulative distribution function of the data. The empirical CDF is the proportion of values less than or equal to X. It is an increasing step function that has a vertical jump of 1/N at each value of X equal to an observed value. Geoscientists involved in geochronological analysis usually use such plots to highlight the cumulative distribution of different zircon populations. The importance of identifying these populations will not be discussed here, however, this is thoroughly explained by other researchers (e.g. Cawood et al., 2012; Barham et al., 2022). The creation of CDF plots can be easily achieved by using the Python programming language. Again, I will be using the Jupyter notebook environment. For this example, I will be using the Sablino Formation data.




After cleaning and filtering the dataset, we can proceed with the Python code. Initially, we import all the packages necessary for plotting cumulative distribution plots.


import pandas as pd
import scipy.stats as stats
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
import numpy as np

We load the excel file with the zircon age data and create a data frame. Check the column name where your ages are stored. In this case, the zircon data corresponds to the age column.


# Load the zircons dataset
data = pd.read_excel('kuznetsov sablino.xlsx')
# Data as a Python Dictionary
dataDictionary = data["age"]
# Create a DataFrame
dataFrame = pd.DataFrame(data = dataDictionary);

Finally, we generate the cumulative distribution function plot. You can set your x and y axes limits by using the plt.xlim and plt.ylim commands. After the image is generated, you can save the image in different file formats, such as .jpg, .pdf., .png, with the plt.savefig command.


plt.style.use('default')
dataDictionary = data["age"]
# Create a DataFrame
dataFrame = pd.DataFrame(data = dataDictionary);
sns.ecdfplot(data = data, x = 'age', color ='#264653')
plt.xlim(0, 3000)
# Plot PDF
plt.savefig('Sablino Formation.pdf', dpi = 200)
plt.show(block=True);

The final result looks like this, and in my case, it is stored as a .pdf file. Afterwards, you can use programs such as Adobe Illustrator to process the image, change the colors, height, width etc. in order to have a good-looking image for your research article.



10 views0 comments

Recent Posts

See All

Comentarios


bottom of page