Skip to content

Instantly share code, notes, and snippets.

@yaojenkuo
Created April 4, 2020 11:29
Show Gist options
  • Select an option

  • Save yaojenkuo/ff0f8bd4fec7a5de3720b3b3a6910ab5 to your computer and use it in GitHub Desktop.

Select an option

Save yaojenkuo/ff0f8bd4fec7a5de3720b3b3a6910ab5 to your computer and use it in GitHub Desktop.
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