Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib plotting a dot every nth x

I'm trying to plot two things:

The first is this:

plotted_values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

I then want to plot a dot every nth value in the plotted values list. Say n is 5:

nth_value_plot = [5, 10]

I want to plot the nth_value_plot values such that the 5 and 10 share the same x, y coordinate as the 5 and 10 in the plotted_values. Plotting as such plots the nth_value_plot with the x coordinates 0 and 1 as expected:

plt.plot(plotted_values)
plt.plot(nth_value_plot, "o")
plt.show()

How do I correctly plot this as described above?

EDIT:

The final plot coordinates (x, y) should be:

plotted_values = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]

nth_value_plot = [[4, 5], [9, 10]]

The current plot from the code above has plotted values with these coordinates and nth_value_plot with the coordinates:

nth_value_plot = [[0, 5], [1, 10]]

Thanks

like image 396
shell Avatar asked Sep 10 '26 06:09

shell


1 Answers

Assuming your x values are the same as your y values:

v = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
n=5
plt.scatter(v[::n],v[::n])

enter image description here

like image 115
atomh33ls Avatar answered Sep 12 '26 20:09

atomh33ls



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!