Converting a line plot to a scatter in Python

Question:

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

Asked By: AEinstein

||

Answers:

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

Answered By: mozway
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.