Home > Blockchain >  Converting a line plot to a scatter in Python
Converting a line plot to a scatter in Python

Time:01-03

I am making a line plot of the array A. Is there a way to convert it to a scatter plot? I present the current output for reference.

import numpy as np
import matplotlib.pyplot as plt


A=np.array([[0.02109   ],
       [0.02109   ],
       [0.0201082 ],
       [0.02109   ],
       [0.02109   ],
       [0.02109   ],
       [0.02055473],
       [0.02055797],
       [0.02109   ],
       [0.02109   ],
       [0.02109   ],
       [0.02109   ]])


plt.title("Line graph")
plt.plot(A, color="red")

The current output is

enter image description here

CodePudding user response:

A scatter plot requires 2 variables, you only have one here.

I believe you rather want a line plot without line and with the individual points:

plt.plot(A, color="red", ls='', marker='o')

Output:

enter image description here

  • Related