How to plot one single data point?

前端 未结 4 581
旧时难觅i
旧时难觅i 2020-12-28 12:46

I have the following code to plot a line and a point:

df = pd.DataFrame({\'x\': [1, 2, 3], \'y\': [3, 4, 6]})
point = pd.DataFrame({\'x\': [2], \'y\': [5]})
         


        
4条回答
  •  轮回少年
    2020-12-28 13:30

    In the last line of the code in question, replace style='-r' with kind='scatter':

    ax = point.plot(x='x', y='y', ax=ax, kind='scatter', label='point')
    

    You can optionally add a color argument to the call to point.plot:

    ax = point.plot(x='x', y='y', ax=ax, kind='scatter', label='point', color='red')
    

提交回复
热议问题