Python Plotting Data Using the Row referring to rows to columns from CSV file
<p>Below is the data from CSV file : Each Value Separated by "COMMA"</p>

<pre><code>SName,Sub1,Sub2,Sub3, ... ,Sub10  
0 A,40,50,33, ... ,78  
1 B,55,55,33, ... ,66  
2 C,99,100,34, ... ,44
</code></pre>

<p>I want to Plot only the Row 0 - that is Student Name: A's subject marks from Sub1 till Sub 10 . The Graph should consist of "BAR" , Bar with different Colours !! depending upon the marks the colours should vary for the Student.</p>

<p>If the a subject has got minimum colour then it show in RED... If a subject has highest marks it should show in another colour. Average marks for other subjects in different colours ? </p>

<p>What should I do?</p>

<p>Possibly the easiest way of many plots is to begin with one of the samples available at the <a href="http://matplotlib.org/gallery.html" rel="nofollow">matplotlib gallery</a>. In this case, I reminded myself about details using two of the samples since I don't use matplotlib often. This code represents part of a solution inasmuch as it does not read values from the csv.</p>

<pre><code>import matplotlib.pyplot as plt
plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt


# Example data
subjects = ['Sub%s'%_ for _ in range(1,11)]
marks = [51,43,55,60,65,43,78,67,88,44]
minMark=min(marks)
maxMark=max(marks)
colors=['green']*len(marks)
for _ in range(len(colors)):
    if marks[_]==minMark:
        colors[_]='red'
    if marks[_]==maxMark:
        colors[_]='yellow'
y_pos = np.arange(len(subjects))

plt.barh(y_pos, marks, align='center',color=colors)
plt.yticks(y_pos, subjects)
plt.xlabel('marks')
plt.title('Subject Marks for Student A')

plt.show()
</code></pre>

<p>With csv filecontents like this:</p>

<pre><code>SName,Sub1,Sub2,Sub3,Sub10  
0,A,40,50,33,78  
1,B,55,55,33,66  
2,C,99,100,34,44
</code></pre>

<p>you can recover the first line of marks using code like this:</p>

<pre><code>import csv

first = True
with open('temp2.csv') as csvfile:
    reader = csv.reader(csvfile)
    for line in reader:
        if first:
            first=False
            continue
        marks=line
        break

print (marks)
</code></pre>

python python-2.7 pandas numpy matplotlib