import numpy as np import matplotlib.pyplot as plt plt.rcParams['font.family'] = 'SimHei' plt.rcParams['axes.unicode_minus'] = False data_5 = np.array([2450,2450,1598,1479.5,1550,1486.5]) data_6 = np.array([1379.5,1378,1350,1338.4,1300,1139.5,1126.5]) data_7 = np.array([1099,1099,1099,1079,1079,1024.5]) data_8 = np.array([1035,1035,1079.5,1126.5,1400,1396,1364.5]) data_9 = np.array([1500,1399,1490,1333.33,1350,1300]) data_10 = np.array([1269.9,1269.4,115,1149.5,1149]) data_11 = np.array([1149,1280,1260,1255,1235,1100]) data_12 = np.array([1040,1040,999,999,938.5]) data_13 = np.array([900,845,894.49,765.49,740,649.5,649.5]) data_14 = np.array([649.47,649.46,649.46,649,639,644]) data_15 = np.array([648.79,649.5,879,799,799,859.89]) data_16 = np.array([857.89,849.99,848.96,848.7,845.9]) plt.boxplot([data_5, data_6, data_7, data_8, data_9, data_10, data_11, data_12, data_13, data_14, data_15, data_16], labels=('5日', '6日','7日','8日','9日','10日' ,'11日','12日','13日','14日','15日','16日') ) plt.show()美化此代码
时间: 2023-07-31 16:12:24 浏览: 136
import numpy as np
import matplotlib.pyplot as plt
# 设置中文字体
plt.rcParams['font.family'] = 'SimHei'
# 解决负号显示问题
plt.rcParams['axes.unicode_minus'] = False
# 数据
data_5 = np.array([2450,2450,1598,1479.5,1550,1486.5])
data_6 = np.array([1379.5,1378,1350,1338.4,1300,1139.5,1126.5])
data_7 = np.array([1099,1099,1099,1079,1079,1024.5])
data_8 = np.array([1035,1035,1079.5,1126.5,1400,1396,1364.5])
data_9 = np.array([1500,1399,1490,1333.33,1350,1300])
data_10 = np.array([1269.9,1269.4,115,1149.5,1149])
data_11 = np.array([1149,1280,1260,1255,1235,1100])
data_12 = np.array([1040,1040,999,999,938.5])
data_13 = np.array([900,845,894.49,765.49,740,649.5,649.5])
data_14 = np.array([649.47,649.46,649.46,649,639,644])
data_15 = np.array([648.79,649.5,879,799,799,859.89])
data_16 = np.array([857.89,849.99,848.96,848.7,845.9])
# 绘制箱线图
plt.boxplot([data_5, data_6, data_7, data_8, data_9, data_10, data_11, data_12, data_13, data_14, data_15, data_16],
labels=('5日', '6日','7日','8日','9日','10日','11日','12日','13日','14日','15日','16日')
)
# 设置标题和坐标轴标签
plt.title('不同日期的数据分布箱线图')
plt.xlabel('日期')
plt.ylabel('数据值')
# 显示图形
plt.show()
阅读全文