Plotting a list of (x, y) coordinates in python matplotlib

后端 未结 3 460
忘掉有多难
忘掉有多难 2020-12-12 12:05

I have a list of pairs (a, b) that I would like to plot with matplotlib in python as actual x-y coordinates. Currently, it is making two plots, whe

3条回答
  •  没有蜡笔的小新
    2020-12-12 12:43

    If you have a numpy array you can do this:

    import numpy as np
    from matplotlib import pyplot as plt
    
    data = np.array([
        [1, 2],
        [2, 3],
        [3, 6],
    ])
    x, y = data.T
    plt.scatter(x,y)
    plt.show()
    

提交回复
热议问题