Ciro Santilli OurBigBook.com  Sponsor 中国独裁统治 China Dictatorship 新疆改造中心、六四事件、法轮功、郝海东、709大抓捕、2015巴拿马文件 邓家贵、低端人口、西藏骚乱
matplotlib/two_lines_column_decide.py.off
#!/usr/bin/env python
"""
Two lines on the same plot.
All points are on a 3 column file, and the first column
decides which line each (x, y) point belongs to.

- http://stackoverflow.com/questions/31863083/python-split-numpy-array-based-on-values-in-the-array
- http://stackoverflow.com/questions/33622888/how-to-plot-2-lines-based-on-the-value-not-column pandas example
"""
import os
import numpy
def plot(plt, params):
    a = numpy.loadtxt(
        os.path.splitext(__file__)[0] + '.dat',
        skiprows=1
    )
    keys = list(set(a[:, 0]))
    for key in keys:
        v = a[a[:, 0] == key, :]
        plt.plot(v[:, 1], v[:, 2], label=int(key))
    plt.legend(loc='upper left')