Plot Demo

Demonstrating the plot methods.

import pandas as pd
import plotly
from plotly.graph_objs import Figure
from elphick.geomet import Sample
from elphick.geomet.utils.data import sample_data

Load Data

We get some demo data in the form of a pandas DataFrame

df_data: pd.DataFrame = sample_data()
df_data.head()
wet_mass mass_dry FE SIO2 al2o3 LOI group
index
0 100.0 90.0 57.0 5.2 3.0 5.0 grp_1
1 90.0 80.0 59.0 3.1 1.7 4.0 grp_1
2 110.0 90.0 61.0 2.2 0.9 3.0 grp_2


Create Sample

obj_smpl: Sample = Sample(df_data)
print(obj_smpl)
Sample: None
{'wet_mass': {0: 300.0}, 'mass_dry': {0: 260.0}, 'H2O': {0: 13.333333333333334}, 'Fe': {0: 59.0}, 'SiO2': {0: 3.5153846153846153}, 'Al2O3': {0: 1.8730769230769235}, 'LOI': {0: 4.0}}

Parallel Plots

Create an interactive parallel plot. Great for visualising and interactively filtering mass-composition data.

fig: Figure = obj_smpl.plot_parallel()
fig


Create a parallel plot with only selected components and color

fig2 = obj_smpl.plot_parallel(vars_include=['wet_mass', 'H2O', 'Fe', 'group'], color='group')
fig2


Ternary Diagram

Create a ternary diagram for any 3 composition variables.

fig3 = obj_smpl.plot_ternary(variables=['SiO2', 'Al2O3', 'LOI'], color='group')
# noinspection PyTypeChecker
plotly.io.show(fig3)  # this call to show will set the thumbnail for use in the gallery

Total running time of the script: (0 minutes 1.561 seconds)

Gallery generated by Sphinx-Gallery