I am new here. I was wandering if there is a simple code to print the number of data points used on a Matplotlib scatterplot and perhaps print it on the plot as "N=...".
Thank you very much
If you need to get back to the data later, and you don't have access to x
and y
anymore for some reason, you can retrieve them like so:
import numpy as np
import matplotlib.pyplot as plt
x = ...
y = ...
artist = plt.scatter(x, y)
# ...
# Things that cause you to lose x and y.
# ...
xy = artist.get_offsets()
x, y = np.array(xy).transpose()
print(len(x))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With