<jupyter_start><jupyter_text>LUCAS – Plot Soil Triangle        This notebook refers to the studies presented in Chapter 4 of the Ph.D. thesis [4].    With this notebook, you can process the raw LUCAS 2012 soil dataset to work with the 1D CNNs [2].    We can not guarantee completeness or correctness of the code.    If you find bugs or if you have suggestions on how to improve the code, we encourage you to post your ideas as GitHub issue.<jupyter_code>%matplotlib inline
%config InlineBackend.figure_format = 'retina'
%load_ext autoreload
%autoreload 2
import matplotlib.pyplot as plt
import matplotlib
import numpy as np
import pandas as pd

import lucas_utils
# CHANGE path to processed file 4_lucas_final.csv
csv_path = "data/4_lucas_final.csv"<jupyter_output><empty_output><jupyter_text>Get data<jupyter_code>df = pd.read_csv(csv_path)
df.shape<jupyter_output><empty_output><jupyter_text>Plot soil triangle<jupyter_code>color = {"super_L": 2, "super_S": 1, "super_T": 4, "super_U": 3}
classes = list(color.keys())
fontsize = 15

def get_color(class_list):
    return [int(color[cl]) for cl in class_list]

fig, ax = plt.subplots(1, 1, figsize=(7, 7))

# colormap
cmap = plt.cm.viridis
cmaplist = [cmap(i) for i in range(cmap.N)]
cmap = matplotlib.colors.LinearSegmentedColormap.from_list('mcm', cmaplist, cmap.N)
bounds = np.linspace(1, 5, 5)
norm = matplotlib.colors.BoundaryNorm(bounds, cmap.N)

ax.scatter(df["clay"], df["silt"],
           c=get_color(df["superclass"].values),
           marker="o", alpha=0.1, cmap=cmap, norm=norm, label="")

ax.set_xlim(0,100)
ax.set_ylim(0,100)
ax.set_xlabel("Clay content in %", fontsize=fontsize, labelpad=15)
ax.set_ylabel("Silt content in %", fontsize=fontsize)
for tick in ax.xaxis.get_major_ticks():
    tick.label.set_fontsize(fontsize)
for tick in ax.yaxis.get_major_ticks():
    tick.label.set_fontsize(fontsize)

    
# plotting empty lists for legend
for c in color.keys():
    ax.scatter(
        [], [],
        c="k",
        label=c[-1])

ax.legend(fontsize=fontsize, title="Soil class:", frameon=False)
legend = ax.get_legend()
legend.get_title().set_fontsize(fontsize)
legend._legend_box.align = "left"
for i, c in enumerate(color.keys()):
    legend.legendHandles[i].set_color(cmap(norm(color[c])))

plt.savefig("plots/soil_map_4categories.pdf", bbox_inches='tight')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12658763759525826, 'fraction_numerical': 0.016088060965283656, 'mean_word_length': 5.09020618556701, 'pattern_counts': {'":': 4, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '327794', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 901, 'n_tokens_neox': 860, 'n_words': 215, 'path': 'py/Plot_SoilTriangle.ipynb', 'repo_name': 'felixriese/lucas-processing', 'size': '2362'}