L1-python/scripts/exp-imp.py

23 lines
478 B
Python
Raw Permalink Normal View History

2022-12-17 15:35:04 +00:00
import numpy as np
import matplotlib.pyplot as plt
x= np.linspace(0,2*np.pi)
y= np.sin(x)
# implicity
plt.plot(x,y,label="sin")
2023-01-18 07:54:52 +00:00
plt.xlabel('x')
plt.ylabel('y')
plt.title("Plot")
2022-12-17 15:35:04 +00:00
plt.legend()
plt.show()
# explicity
fig = plt.figure(figsize=(6,6))
ax = plt.subplot(aspect=1)
ax.plot(x,y,label="sin")
ax.set_xlabel('x') # Add an x-label to the axes.
ax.set_ylabel('y') # Add a y-label to the axes.
2023-01-18 07:54:52 +00:00
ax.set_title("Plot") # Add a title to the axes.
2022-12-17 15:35:04 +00:00
ax.legend() # Add a legend.