Line plot with arrows in matplotlib

前端 未结 2 1785
说谎
说谎 2020-12-01 06:17

I have a line graph that I want to plot using arrows instead of lines. That is, the line between successive pairs of points should be an arrow going from the first point to

相关标签:
2条回答
  • 2020-12-01 06:55

    You could superpose a quiver plot on your line plot.

    0 讨论(0)
  • 2020-12-01 06:58

    You can do this with quiver, but it's a little tricky to get the keyword arguments right.

    import numpy as np
    import matplotlib.pyplot as plt
    
    x = np.linspace(0, 2*np.pi, 10)
    y = np.sin(x)
    
    plt.figure()
    plt.quiver(x[:-1], y[:-1], x[1:]-x[:-1], y[1:]-y[:-1], scale_units='xy', angles='xy', scale=1)
    
    plt.show()
    

    enter image description here

    0 讨论(0)
提交回复
热议问题