import matplotlib matplotlib.use('TkAgg') import matplotlib.pyplot as plt import seaborn as sns # 数据 data = [ 1932.66, 1989.13, 1929.06, 1898.24, 1925.99, 1952.25, 1934.15, 1911.27, 2039.49, 1916.57, 1956.14, 1976.60, 1943.77, 1979.83, 2007.93, 1948.32, 1926.80, 1957.77, 2018.95, 1955.47, 1936.28, 1964.59, 2001.86, 2000.46, 1983.32, 1944.21, 1965.44, 1919.20, 1927.22, 1914.22, 1951.30, 2073.96, 1951.65, 1922.66, 1938.83, 1940.89, 1935.30, 1929.83, 1920.31, 1936.84, 1903.23, 1961.68, 1910.05, 1967.49, 1944.28, 1929.93, 1947.74, 1998.52, 2084.09, 1984.61, 1883.19, 1911.96, 1933.98, 1879.84, 1964.32, 1925.98, 1951.21, 1924.62, 1987.16, 1927.16, 1889.64, 1923.81, 1928.60, 1905.86, 1950.55, 1998.71, 2006.41, 1912.82, 1902.13, 1971.55, 1896.19, 1942.12, 1928.60, 1913.60, 1957.83, 1929.95, 1953.88, 1909.56, 1930.49, 2011.94, 1985.11, 1929.07 ] # 设置样式,移除背景条纹并设置背景为白色 sns.set(style="ticks", rc={"axes.facecolor": "white"}) # 创建绘图对象 plt.figure(figsize=(12, 8)) # 使用seaborn绘制概率密度分布图,保留线条底纹 sns.kdeplot(data, shade=True, color="green", label="Density") # 添加图表标题和轴标签 plt.title('An underground mine in ChangZhi', fontsize=20, weight='bold') plt.xlabel('Methane concentration/ppb', fontsize=14) plt.ylabel('Probability density', fontsize=14) # 添加图例 plt.legend(title='Legend', title_fontsize='13', fontsize='12') # 调整网格线样式 plt.grid(True, linestyle='--', linewidth=0.5) # 显示图表 plt.show()
12-21
11-10
9582
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-12