土壤质地三角形
土壤质地三角形是用于描述土壤中不同粒径颗粒的相对含量的图形工具。这个图形以三个主要颗粒尺寸为基础,它们分别是沙、粉土和黏土。土壤质地三角形的三边分别代表这三种颗粒的百分比含量,形成一个三角形。
在土壤质地三角形中,三个角分别表示100%的沙、粉土和黏土。通过连接这些角,形成的三角形区域表示不同混合比例下的土壤质地。例如,如果一个土壤样品在三角形的中心,那么它包含相等比例的沙、粉土和黏土。如果样品靠近某一边,表示该土壤含有更高比例的对应颗粒。
这种图形有助于农业、土壤科学和土木工程领域的专业人士理解土壤的物理性质。通过了解土壤中各种颗粒的相对含量,可以更好地了解土壤的排水性、通气性、保水性等特性,从而指导相应的土壤管理和土壤改良措施。
pyrolite
这是一个主要用于地球化学领域的python库,地球化学方向的小伙伴可以研究下这个库。网址:pyrolite
这是一些绘图模板,此次土壤质地三角形主要采用Ternary Color Systems模板。
python代码
import matplotlib.pyplot as plt
from pyrolite.util.classification import USDASoilTexture
from pyrolite.util.plot.style import color_ternary_polygons_by_centroid
from pyrolite.util.synthetic import normal_frame
clf = USDASoilTexture()
ax = clf.add_to_axes(ax=None, add_labels=True, figsize=(8, 8))
# color_ternary_polygons_by_centroid(ax)
# plt.show()
color_ternary_polygons_by_centroid(
ax, colors=("red", "green", "blue"), coefficients=(1, 1, 1), alpha=0.5
)
plt.show()
结果展示:
现在我想随机生成一些土壤组成数据投影到土壤质地三角形中,你也可以使用自己的土壤组成数据进行替换。
import matplotlib.pyplot as plt
import numpy as np
from pyrolite.util.classification import USDASoilTexture
from pyrolite.util.plot.style import color_ternary_polygons_by_centroid
from pyrolite.util.synthetic import normal_frame
import pandas as pd
clf = USDASoilTexture()
ax = clf.add_to_axes(ax=None, add_labels=True, figsize=(8, 8))
# Plot ternary polygons
color_ternary_polygons_by_centroid(ax, colors=("red", "green", "blue"), coefficients=(1, 1, 1), alpha=0.5)
# Create some example data
df = pd.DataFrame(data=np.exp(np.random.rand(100, 3)), columns=['Clay', 'Sand', 'Silt'])
# Project scatter plot onto the ternary diagram
df.pyroplot.scatter(ax=ax, c="yellow", label="Soil Composition", alpha=0.5)
# Show the plot
plt.legend(bbox_to_anchor=(0.8, 1))
plt.show()
结果展示: