A note for Python beginners. Please be careful about mistakes in the content.
import matplotlib.pyplot as plt
import numpy as np
def test():
x = np.array([1,2,3,4,5])
y = np.array([1,2,3,4,5])
plt.plot(x, y, 'o', label="x and y")
plt.legend()
plt.show()
plt.plot(x, y, 'o', label="x and y")
plt.legend (numpoints = 1) # set numpoints to 1 plt.show()
if __name__ == '__main__':
test()
Before:
After:
Recommended Posts