我需要通过在“x”中显示“o”来编辑图例,我用它来标记曲线的某些部分,但我无法解决这个问题,因为我使用了一种复杂的方法来突出显示高和低的部分
fig = plt.figure(figsize=(20, 15))
ax = fig.add_subplot( 2, 1, 1 )
bx = fig.add_subplot( 2, 1, 2 )
ax.plot( time1List, tempList, marker='x', linestyle='', zorder=100 )
ax.plot( time2List, fit_func( time2List, *sol ), zorder=0 )
ax.set_title('Fitting whole MPs on standrad thermal profile ', fontweight='bold', fontsize=25)
ax.set_xlabel('cycles', fontsize=20)
ax.set_ylabel('Thermal regime', fontsize=20)
ax.set_yticks( [-40,-20,0,25,50,75,100,125,150] )
#patch = Patch(facecolor='orange', edgecolor='r', label='Color patch')
#lgd = ax.legend(handles=[time1List, time2List, patch], loc='lower right')
#add_patch(lgd)
#ax.legend(loc='best')
red_patch = mpatches.Patch(color='red', label='High regime')
blue_patch = mpatches.Patch(color='blue', label='Low regime')
plt.legend(handles=[red_patch, blue_patch], loc='best', fontsize=20)
bx.plot( time1List, tempList, marker='x', linestyle='' )
bx.plot( time2List, fit_func( time2List, *sol ) )
bx.plot( rampX, rampY, linestyle='', marker='o', markersize=10, fillstyle='none', color='r')
bx.plot( topX, topY, linestyle='', marker='o', markersize=10, fillstyle='none', color='#00FFAA')
bx.plot( botX, botY, linestyle='', marker='o', markersize=10, fillstyle='none', color='#80DD00')
bx.set_title('Fitting part of MPs on standrad thermal profile ', fontweight='bold', fontsize=25)
bx.set_xlabel('cycles', fontsize=20)
bx.set_ylabel('Temperature [℃]', fontsize=20)
bx.set_xlim( [ 0, 800 ] )
plt.show()
有什么建议可以解决这个问题吗
你两次密谋要得到那个十字准线标记。你将无法用任何标准方法创建带有十字准线的图例,这种方法与你创建该标记的方法相同
可以使用
$\\bigotimes$
直接获取标记。那么使用legend
就很简单了。只需为绘图中的每个对象定义label
,以便在图例中显示:相关问题 更多 >
编程相关推荐