Created
April 4, 2020 11:29
-
-
Save yaojenkuo/ff0f8bd4fec7a5de3720b3b3a6910ab5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| def plot_sin(ax_obj, x_arr, y_arr): | |
| ax_obj.plot(x, y) | |
| ax_obj.set_title("$y = sin(x)$") | |
| ax_obj.set_xlabel("x") | |
| ax_obj.set_ylabel("y") | |
| ax_obj.set_xticks([0, np.pi, 2*np.pi]) | |
| ax_obj.set_xticklabels(['0', '$\pi$', '$2\pi$']) | |
| x = np.linspace(0, 2*np.pi) | |
| y = np.sin(x) | |
| fig = plt.figure() | |
| ax = plt.axes() | |
| plot_sin(ax, x, y) | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment