# -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt from matplotlib.font_manager import FontProperties # 设置中文字体 font = FontProperties(fname='C:/Windows/Fonts/simsun.ttc') # 你可以根据需要更改字体路径 # 定义温度和对应的平衡值数据 USE_EPM = False # 是否使用EPM数据,True为EPM数据,False为SMASON数据 if USE_EPM: #-----------------改EPM----------------- temperatures = [-16,-6,0,7,15,17,21,25,28,35,45,51] balance_values_0 = [1188,1222,1223,1233,1225,1255,1247,1268,1253,1230,1206,1175] balance_values_50 = [1450,1465,1464,1469,1473,1480,1470,1470,1472,1460,1418,1365] balance_values_100 = [1720,1781,1745,1776,1721,1742,1768,1774,1723,1724,1606,1529] else: #-----------------SMASON----------------- temperatures = [16,20,25,29,35,39,45,50,55,60,65,70,77,80,85] balance_values_0 = [1732,1673,1700,1734,1701,1728,1721,1706,1705,1733,1693,1676,1720,1712,1670] balance_values_50 = [1948,1958,1953,1985,1955,1949,1966,1935,1974,1966,1954,1961,1955,1967,1909] balance_values_100 = [2237,2214,2281,2266,2279,2268,2276,2268,2263,2285,2266,2276,2232,2245,2241] # 创建一个图形对象 plt.figure() # 绘制数据 plt.plot(temperatures, balance_values_0, marker='o', label='0% 平衡值',color='green') plt.plot(temperatures, balance_values_100, marker='o', label='100% 平衡值',color='blue') plt.plot(temperatures, balance_values_50, marker='o', label='50% 平衡值',color='red') # 在坐标点上绘制温度值 for i in range(len(temperatures)): plt.text(temperatures[i], balance_values_0[i], f'{temperatures[i]}°C', fontproperties=font) plt.text(temperatures[i], balance_values_100[i], f'{temperatures[i]}°C', fontproperties=font) plt.text(temperatures[i], balance_values_50[i], f'{temperatures[i]}°C', fontproperties=font) # 添加标题和标签 if USE_EPM: plt.title('[自研EPM]温度变化对0%、100% 平衡值驱动的影响', fontproperties=font) else: plt.title('[SAMSON的EPM]温度变化对0%、100% 平衡值驱动的影响', fontproperties=font) plt.xlabel('温度 (°C)', fontproperties=font) plt.ylabel('平衡值', fontproperties=font) plt.legend(prop=font) # 显示图形 plt.show()