【问题标题】:How do I plot data in a text file depending on the the value present in one of the columns如何根据其中一列中的值在文本文件中绘制数据
【发布时间】:2020-02-16 21:48:12
【问题描述】:

我有一个带有标题和几列的文本文件,它代表实验的结果,其中一些参数被固定以获得一些指标。文件格式如下:

     A    B     C     D     E
0  0.5  0.2  0.25  0.75  1.25
1  0.5  0.3  0.12  0.41  1.40
2  0.5  0.4  0.85  0.15  1.55
3  1.0  0.2  0.11  0.15  1.25
4  1.0  0.3  0.10  0.11  1.40
5  1.0  0.4  0.87  0.14  1.25
6  2.0  0.2  0.23  0.45  1.55
7  2.0  0.3  0.74  0.85  1.25
8  2.0  0.4  0.55  0.55  1.40

所以我想为 And E 的每个固定值绘制 x = B, y = C 所以基本上对于 E=1.25 我想要在 A 的每个值处绘制一系列 x = B, y = C 的线图然后E 的每个唯一值的图。

有人可以帮忙吗?

【问题讨论】:

    标签: python-2.7 matplotlib


    【解决方案1】:

    您可以组合使用groupby()seaborn.lineplot()

    for e,d in df.groupby('E'):
        fig, ax = plt.subplots()
        sns.lineplot(data=d, x='B', y='C', hue='A', ax=ax)
        ax.set_title(e)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-07
      • 1970-01-01
      • 2023-03-29
      • 2018-12-05
      • 1970-01-01
      • 2020-10-14
      • 1970-01-01
      相关资源
      最近更新 更多