【发布时间】:2019-09-01 21:15:19
【问题描述】:
我需要通过在“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()
关于如何解决此问题的任何建议?
【问题讨论】:
-
代码有很多不相关的细节,但我找不到你在哪里画这些标记。
标签: python matplotlib legend