मैं फ्लोट की ग्राफ सूची में 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 लाइनों कॉपी बदल सकते हैं। आपको लंबाई चर को फ़ाइल में लाइनों की संख्या में बदलना चाहिए।
धन्यवाद।