Dashed lines from points to axes in matplotlib

后端 未结 2 1102
再見小時候
再見小時候 2020-12-29 14:13

I have a set of points which I am plotting like this:

import matplotlib.pyplot as plt`

x = [1,2,3,4,5,6]
y = [1,4,9,16,25,36]

plt.scatter(x, y)

plt.show()         


        
2条回答
  •  旧巷少年郎
    2020-12-29 14:36

    The plot you're looking for is what's known as a stemplot, which has an answer you can find here. It will give you the vertical line connections to the x-axis you desire; but if you want the horizontal lines connecting to the y-axis that may need some special treatment. You may be able to use a stem plot in the other axis rotated or something.

提交回复
热议问题