Plotting lines connecting points

前端 未结 4 1741
挽巷
挽巷 2020-12-03 02:32

I know there is another very similar question, but I could not extract the information I need from it.

plotting lines in pairs

I have 4 points in the (

4条回答
  •  死守一世寂寞
    2020-12-03 03:25

    I think you're going to need separate lines for each segment:

    import numpy as np
    import matplotlib.pyplot as plt
    
    x, y = np.random.random(size=(2,10))
    
    for i in range(0, len(x), 2):
        plt.plot(x[i:i+2], y[i:i+2], 'ro-')
    
    plt.show()
    

    (The numpy import is just to set up some random 2x10 sample data)

提交回复
热议问题