I use Matplotlib to display a list of floats. If there is a 100 float on my list, the graph displays the correct colors. But if there is a float in the list of 785, then it shows only black color. Here is the code.
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)
width = 1
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')
This is an image of a program when the list is 785 in length.

This is when the list is 99 in length.

The file is available here - http://pastebin.com/HhPhgPDG
You can change only copy the first 100 lines of this file to check another case. You must change the length variable to the number of lines in the file.
Thank.
source
share