2015-01-07 2 views
0

json 파일의 내용을 플롯하려고합니다. 스크립트는 64 개의 서브 플로트를 생성해야합니다. 각 서브 플롯은 128 개의 샘플 (전압 레벨)로 구성됩니다. "ElementSig"는 해당 json 파일에서 8192 개의 샘플 목록에 대한 "키"입니다. 나는 한 번에 128 개 개의 샘플을 채취하고 내 다음 스크립트에서 참조로의 부가 적 줄거리를 생성하고 : 결과는 매우 가득matplotlib을 사용하여 부 그림 구성

import json 
import matplotlib.pyplot as plt 
json_data = open('txrx.json') 
loaded_data = json.load(json_data) 
json_data.close() 
j = 0 
E = loaded_data['ElementSig'] 

for i in range(64): 
    plt.ylabel('E%s' % str(i+1)) 
    print 'E', i, ':' 
    plt.figure(1) 
    plt.subplot(64, 2, i+1) 
    print E[0+j:127+j] 
    plt.plot(E[0+j:127+j]) 
    j += 128 
plt.show() 

를하고, 수치는 중복된다. enter image description here

도움을 주시면 감사하겠습니다.

답변

0

.png 파일로 저장할 때 더 좋은 그림이 있습니다.

fig = plt.figure(figsize=(20, 222)) 
plt.subplots_adjust(top=.9, bottom=0.1, wspace=0.2, hspace=0.2) 

for i in range(1, 65): 

    print 'E', i, ':' 

    plt.subplot(64, 2, i) 
    plt.ylabel('E%s' % str(i)) 

    i += 1 
    print E[0+j:127+j] 
    plt.plot(E[0+j:127+j]) 
    j += 128 
plt.savefig('foo.png', bbox_inches='tight') 
plt.show() 

더 나은 해결책이 있다고 생각하지만.

관련 문제