Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plot entire row on pandas

I have an entire row from the matrix. And I try to do bar plot.I try to find any examples but I couldn't so, can somebody help me?

In [9]:Atot1
Out[9]: 
     T    G    C   -    A    C    T   -    A    G    T   -    A    G    C   
SAMPLE                                                                          
1       97  457  178  75  718  217  193  69  184  198  777  65  100  143  477   

     -   A   T   G   C  
SAMPLE                      
1       54  63  43  55  47  
like image 700
kant Avatar asked Aug 19 '15 21:08

kant


1 Answers

Select the row:

row = df.iloc[0]

Plot the row (a pandas.Series):

row.plot(kind='bar')

For example,

import pandas as pd
import matplotlib.pyplot as plt

d = {'columns': ['T', 'G', 'C', '-', 'A', 'C', 'T', '-', 'A', 'G', 'T', 
                 '-', 'A', 'G', 'C', '-', 'A', 'T', 'G', 'C'],
     'data': [[97, 457, 178, 75, 718, 217, 193, 69, 184, 198,
               777, 65, 100, 143, 477, 54, 63, 43, 55, 47]],
     'index': [1]}
df = pd.DataFrame(d['data'], columns=d['columns'], index=d['index'])
df.columns.names = ['SAMPLE']

row = df.iloc[0]
row.plot(kind='bar')
plt.show()

yields

enter image description here

like image 51
unutbu Avatar answered Oct 26 '22 03:10

unutbu