Matplotlib: Draw lines from x axis to points

前端 未结 2 1588
不知归路
不知归路 2021-02-13 22:26

I have a bunch of points that I am trying to plot using matplotlib. For each point (a,b) I want to draw the line X = a for Y in [0,b]. Any idea how to do this?

2条回答
  •  爱一瞬间的悲伤
    2021-02-13 23:06

    Use a stem plot

    The least cumbersome solution employs matplotlib.pyplot.stem

    import matplotlib.pyplot as plt
    x = [1. , 2., 3.5]
    y = [2.3, 4., 6.]
    plt.xlim(0,4)
    plt.stem(x,y)
    plt.show()
    

提交回复
热议问题