画kde图像

147 阅读1分钟
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

# 假设这是五种货币的价格数据,这里使用NumPy数组进行展示
currency_data = [np.random.normal(loc=1.2, scale=0.1, size=1000),
                np.random.normal(loc=1.3, scale=0.15, size=1000),
                np.random.normal(loc=1.1, scale=0.05, size=1000),
                np.random.normal(loc=1.4, scale=0.2, size=1000),
                np.random.normal(loc=1.0, scale=0.1, size=1000)]

# 货币名称
currencies = ['Currency A', 'Currency B', 'Currency C', 'Currency D', 'Currency E']

# 设置图形的宽度和高度
plt.figure(figsize=(10, 6))

# 绘制五种货币的密度曲线
for i, currency in enumerate(currencies):
    sns.kdeplot(currency_data[i], label=currency)

# 设置X轴的标签
plt.xlabel('Price')

# 设置Y轴的标签
plt.ylabel('Density')

# 添加图例
plt.legend()

# 显示图形
plt.show()