Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Converting a line plot to a scatter in Python

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading