플로트 목록을 그래프로 나타 내기 위해 Matplotlib을 사용하고 있습니다. 내 목록이 100 개의 부동 소수점이면 그래프에 적절한 색이 표시됩니다. 그러나 목록이 785 개가 넘으면 검은 색으로 만 표시됩니다. 여기에 코드가 있습니다.Matplotlib - 왜 막대 그래프의 선 색상이 검정입니까?
import numpy as np
import matplotlib.pyplot as plt
import Image
Consensus = []
Prediction = []
Final = []
for line in open('1.out').readlines():
words = line.split()
Consensus.append(float(words[10]))
Prediction.append(int(words[11]))
for i,j in zip(Consensus,Prediction):
Final.append(i*j)
max_score = 3
length = 785
ind = np.arange(length) # the x locations for the groups
width = 1 # the width of the bars: can also be len(x) sequence
p1 = plt.bar(ind, Consensus, width, color='red')
p2 = plt.bar(ind, Final, width, color='blue')
plt.ylabel('Scores')
plt.title('Scores by group and gender')
plt.xticks(np.arange(0,length,50))
plt.yticks(np.arange(0,max_score,0.2))
plt.savefig('testplot.png')
Image.open('testplot.png').save('testplot.jpg','JPEG')
이것은 목록의 길이가 785 일 때의 프로그램 사진입니다.
이것은 목록의 길이가 99 인 경우입니다.
파일은 여기에서 확인할 수 있습니다 - http://pastebin.com/HhPhgPDG
당신은 단지 다른 경우를 확인하기 위해이 파일의 첫 100 줄을 복사 변경할 수 있습니다. 길이 변수를 파일의 행 수로 변경해야합니다.
감사합니다.