plt.plot line joined by different colour dots - without scatter

Viewed 22

I do not want to use scatter as I am trying to overlay the line y=x on some unknown and weirdly scaled data.

plt.plot(xdata, ydata, "-ro")

Gives me a line with red dots on data points, is it possible to get different colour dots without having to use scatter?

Using the top answer from Adding y=x to a matplotlib scatter plot if I haven't kept track of all the data points that went in . My result is as follows: enter image description here

The images axes are squished and some points are not near in the full plot. MFE:

fig = plt.figure(figsize=(8,8))
graph = fig.add_subplot(111)
ax = graph.axes
small_x = [0.002, 0.04, 0.1, 0.005]
med_y = [25, 28, 24, 30, 12]
for val1, val2 in zip(small_x, med_y):
    graph.scatter(val1, val2)

lims = [
    np.min([ax.get_xlim(), ax.get_ylim()]),  # min of both axes
    np.max([ax.get_xlim(), ax.get_ylim()]),  # max of both axes
]

# now plot both limits against eachother
ax.plot(lims, lims, 'k-', alpha=0.75, zorder=0)
ax.set_aspect('equal')
ax.set_xlim(lims)
ax.set_ylim(lims)
plt.show()
0 Answers
Related