I was trying to plot some points as single pixels in my mollweide projection when I realized that the points got automatically connected by lines made of the same kind of marker. (see image below) My final application is plotting stars in the sky, given ICRS coordinates.
I found ways to avoid this problem using plt.scatter (see below with squared markers) or using healpy, but is it possible to plot the points with plt.plot without being connected by lines? Here is an simple example code and its output:
from matplotlib import pyplot as plt
import numpy as np
fig = plt.figure()
plt.subplot(111, projection="mollweide")
x = np.array([-np.radians(120), 0, np.radians(120)])
y = np.array([0, np.radians(30), 0])
plt.plot(x, y, ',')
plt.scatter(x, y, marker=',')
plt.grid(), plt.show()
fig.savefig('example.png')
output:
EDIT:
where I used plt.scatter()
to show a possible workaround (the marker would then have to be personalized).
note that plt.plot(x,y,',')
behave as desired when no projection is used as show in the following plot:
reference plot without projection
(where I plotted the red circles to show the small plotted blue pixels that plt.plot()
plotted as desired).
I want to achieve it with plt.plot()
as it should be faster for this kind of task: The plot function will be faster for scatterplots where markers don't vary in size or color. said on the documentation page of scatter(here)
EDIT_2:
It is not a duplicate since setting linestyle='None'
as suggested in the suggested question does not resolve the problem what so ever. This is probably since thoses "lines" are not real lines but markers plotted in between the points acting as virtual lines.