Vertical lines to points in scatter plot

后端 未结 2 1300
野趣味
野趣味 2021-01-17 15:59

Suppose I have a set of points x and a set of corresponding data y. I now plot these in a scatter plot, plt.scatter(x,y). The figure I

2条回答
  •  Happy的楠姐
    2021-01-17 16:26

    Well, there is a stem method, much easier to use:

    import matplotlib.pyplot as plt
    import numpy as np
    
    x, y = np.random.random((2, 20))
    
    fig, ax = plt.subplots()
    ax.stem(x, y, markerfmt=' ')
    plt.show()
    

    If you want bullets on the top of lines, just remove markerfmt.

提交回复
热议问题