mikhail_dvorkin icon

PyPlot example

mikhail_dvorkin | PRO | 03/17/16 11:08:52 AM UTC | 0 ⭐ | 619 šŸ‘ļø | Never ā° | []
Python |

650 B

|

None

|

0 šŸ‘

/

0 šŸ‘Ž

import matplotlib.pyplot as plt
import numpy as np
Ā 
plt.figure(figsize=(6, 6))
x = np.linspace(-np.pi, np.pi)
y = np.sin(x)
z = np.cos(x)
plt.plot(x, y, "o", color="orange", label="sin")
plt.plot(x, z, "v", label="cos")
plt.xlim(-np.pi, np.pi)
plt.xticks([-np.pi/2, 0, np.pi/2], [r"$-\frac{\pi}{2}$", "$x^2$", r"$\frac{\pi}{2}$"])
plt.ylim(-np.pi, np.pi)
plt.scatter(1, 1, color="red")
plt.scatter([1, 1.1, 1.2], [1.2, 1.1, 1], color="orange")
plt.annotate("max of sin", xy=(x[np.argmax(y)], np.max(y)))
plt.legend(loc="upper left")
#plt.plot(x, y, linestyle="-")
a = np.random.random_sample(10)
b = np.random.random_sample(10)
#plt.plot(a, b)

Comments