import matplotlib.pyplot as plt import numpy as np x = np.arange(-2, 2, 0.1) y1 = np.sin(2 * np.pi * x) y2 = np.cos(2 * np.pi * x) plt.plot(x, y1, color="red", linestyle="solid", label="sin(x)") plt.plot(x, y2, color="blue", linestyle="dashed", label="cos(x)") plt.title("Sin / Cos") plt.xlabel("x") plt.ylabel("y") plt.legend() plt.show() plt.savefig("test.png")
import matplotlib.pyplot as plt import numpy x = numpy.random.randint(1, 101, size=20) y = numpy.random.randint(1, 101, size=20) plt.scatter(x, y, c="blue") for data in zip(x, y): plt.annotate(str(data), data) plt.title("Test plot") plt.xlabel("x") plt.ylabel("y") plt.show() plt.savefig("test.png")