2017-09-20 1 views
0

으로 목록 분리의 각 항목에서 ax.annotate 나는 정의 된 줄 바꿈과 ax.annotate에 의해 부가 적 줄거리 상자에이를 인쇄하고자하는 항목 proteinlabel하기 matplotlib : 개행

proteinlabel = ['K{} - {}\nsum: {:.2e} mean: {:.2e}\n'.format(i+1, name, Harea.sum(), Harea.mean()) 
       for i, (name, Harea) in enumerate(zip(uniprot_label, prot_nHarea))] 

print proteinlabel 
OUT>> ['K1 - Albumin, Recombinant human\nsum: 1.00e+12 mean: 3.70e+06\n', 'K2 - Antithrombin III from plasma\nsum: 9.36e+11 mean: 5.20e+06\n', 'K3 - Annexin V from human placenta\nsum: 6.79e+11 mean: 6.85e+06\n'] 

의 목록을 만들 수 있지만 목록입니다 표시된 정확히 OUT>>처럼 \n은 개행 문자로 작동하지 않습니다.

ax2 = plt.subplot2grid((8, 10), (6, 0), rowspan=2, colspan=4) 
ax2.annotate(proteinlabel, xy=(0.5, 0.5)) 

enter image description here

어떻게 ax.annotate (또는 다른 더 나은 방법)을 부가 적 줄거리 상자에 의해 줄 바꿈에 의해 분리 목록의 각 항목을 인쇄하려면? 예

K1 - Albumin, Recombinant human 
sum: 1.00e+12 mean: 3.70e+06 
K2 - Antithrombin III from plasma 
sum: 9.36e+11 mean: 5.20e+06 
K3 - Annexin V from human placenta 
sum: 6.79e+11 mean: 6.85e+06 

답변

1

이 목록은 텍스트 자체가 아닌 텍스트로 인쇄됩니다. 먼저 목록을 문자열로 만든 다음 올바르게 해석 할 수 있습니다.

ax2 = plt.subplot2grid((8, 10), (6, 0), rowspan=2, colspan=4) 
ax2.annotate("".join(proteinlabel) , xy=(0.5, 0.5))