使用matplotlib的线图,用于200列的数据帧

时间:2016-02-29 14:27:35

标签: python pandas matplotlib ggplot2 dataframe

我正在努力为我拥有的数据框架绘制线图。数据框由200列和约4900行组成。 它的数据框头部如下所示,

Geneid  pool16.1    pool18.13   pool14.11   pool15.6    pool15.2    pool17.1    pool14.16   pool14.9    pool15.10   ... pool3.13    pool2.3 pool4.7 pool1.16    pool3.14    pool1.14    pool2.14    pool8.7 pool9.15    pool10.11
0   ABL1.exon1  1073    594 901 1164    1117    1681    1516    914 1002    

    ... 1471    1086    1032    1600    1023    1203    1465    546 650 947
    1   ABL1.exon2  974 549 738 1006    1057    1463    1463    783 1334    ... 1288    1095    967 1474    881 1134    1326    595 505 912
    2   ABL1.exon3  701 619 471 748 732 1043    1145    531 935 ... 1031    871 702 1206    771 985 1236    301 301 710
    3   ABL1.exon4  555 225 371 586 559 842 830 402 636 ... 831 621 555 887 575 726 936 359 238 556
    4   ABL1.exon5  1063    524 817 1085    1086    1624    1448    843 1368    ... 1523    1234    1185    1883    1025    1387    1655    732 581 882
    5 rows × 199 columns

所以我想从上面的dataFrame中绘制一个折线图,这是我试过的,当用一小部分数据框进行绘图时,

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
plt.style.use('ggplot')


CDKN2A= All_pools[All_pools.Geneid.str.contains("CDKN2A") == True]

CDKN2A.plot.line(figsize=(15,10),x='Geneid',y='value')

这给出了这样的情节,

enter image description here

我没有关于x轴上第一列的信息,而且该图没有提供信息。我的目标是绘制一些看起来像这样的东西,

enter image description here

情节看起来如此紧张,没有多少信息......任何让它看起来更好的建议都会很棒..

1 个答案:

答案 0 :(得分:0)

如果要在x轴上查看日期,则需要在数据框中包含日期的列。

如果你想看到几行,你需要绘制几列。

如果要查看实际的不同行,则需要绘制较少的行或更多自相关数据或两者。

您已经有关于x轴上第一列的信息:列名和一些标记的值,像往常一样。