import ternary
# We tested using ternary V.1.0.8
print(ternary.__version__)
1.0.8
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import Thermobar as pt
from scipy import interpolate
out=pt.import_excel('Two_Feldspar_input.xlsx', sheet_name="Paired_Plag_Kspar")
# This extracts a dataframe of all inputs
my_input=out['my_input']
# This extracts a dataframe of kspar compositions from the dictionary "out"
Kspars=out['Kspars']
# This extracts a dataframe of plag compositions from the dictionary "out"
Plags=out['Plags']
Kspar_tern_points = pt.tern_points_fspar(fspar_comps=Kspars)
Plag_tern_points = pt.tern_points_fspar(fspar_comps=Plags)
But you can change any of these using Sanidine_label='Sanidine' 5. The font size ofthe component labels (default 10), e.g., if you go for full words, you might need to reduce the font size, e.g., fontsize_component_labels=6. 6. The font size of the axes labels (default 14). 7. major_grid_kwargs, this sets the colors, by default, its grey.
fig, tax = pt.plot_fspar_classification()
fig.tight_layout()
fig, tax = pt.plot_fspar_classification(labels=True)
fig.tight_layout()
fig, tax = pt.plot_fspar_classification(labels=True,
Sanidine_label='Sanidine')
fig.tight_layout()
fig, tax = pt.plot_fspar_classification(labels=True, major_grid=True)
fig.tight_layout()
fig, tax = pt.plot_fspar_classification(labels=True, major_grid=True, major_grid_kwargs={"ls": ":", "lw": 0.5, "c": "magenta"})
fig.tight_layout()
fig, tax = pt.plot_fspar_classification(labels=True, major_grid=True, minor_grid=True)
fig.tight_layout()
fig, tax = pt.plot_fspar_classification(labels=True, major_grid=True, minor_grid=True, ticks=False)
fig.tight_layout()
...and some random customizations to show flexibility
# Calling tern_points function for plag and kspar data
# make the figure with the classification lines as in the examples above.
fig, tax = pt.plot_fspar_classification(major_grid=True, ticks=False)
# Here we plot the data ontop, with plag as red triangles
tax.scatter(
Plag_tern_points,
edgecolor="k",
marker="^",
facecolor="red",
label='Plag',
s=90
)
# And Kspars as blue dots
tax.scatter(
Kspar_tern_points,
edgecolor="k",
marker="o",
facecolor="cyan",
s=60, label='Kspar'
)
tax.legend(loc='upper left')
fig.tight_layout()
fig.savefig('Simple_Plag_fspar.png', dpi=200)
# make the figure with the classification lines as in the examples above.
fig, tax = pt.plot_fspar_classification(figsize=(6, 5), major_grid=True, ticks=False, )
# Here, we color based on the Cation proportion of FeOt in plag.
# Vmin and vmax just resets the colorbar (by default it does weird things)
# Here, we use the same colorbar for both plots.
tax.scatter(
Plag_tern_points,
c=Plags["FeOt_Plag"],
vmin=np.min([Plags["FeOt_Plag"], Kspars["FeOt_Kspar"]]),
vmax=np.max([Plags["FeOt_Plag"], Kspars["FeOt_Kspar"]]),
s=70,
edgecolor="k",
cmap="hot",
colormap="hot",
)
tax.scatter(
Kspar_tern_points,
c=Kspars["FeOt_Kspar"],
vmin=np.min([Plags["FeOt_Plag"], Kspars["FeOt_Kspar"]]),
vmax=np.max([Plags["FeOt_Plag"], Kspars["FeOt_Kspar"]]),
edgecolor="k",
s=70,
cmap="plasma",
colormap="plasma",
colorbar=True,
cb_kwargs={"shrink": 0.5, "label": "FeOt content"},
)
fig.savefig('Fspar_colored_by_FeOt.png', dpi=200)
# make the figure with the classification lines as in the examples above.
fig, tax = pt.plot_fspar_classification(figsize=(6, 6), major_grid=True, ticks=False)
# Here, we color based on the Cation proportion of FeOt in plag.
# Vmin and vmax just resets the colorbar (by default it does weird things)
# Here, we use the same colorbar for both plots.
tax.scatter(
Plag_tern_points,
s=200*Plags["FeOt_Plag"]+30,
edgecolor="k",
marker="^"
)
tax.scatter(
Kspar_tern_points,
c=Kspars["FeOt_Kspar"],
s=200*Kspars["FeOt_Kspar"]+30,
edgecolor="k",
marker="o"
)
<AxesSubplot:>