Skip to content

Instantly share code, notes, and snippets.

@CodeMaster7000
Last active February 15, 2023 16:42
Show Gist options
  • Save CodeMaster7000/9384860f99a9e58a1a0653e9eccb6ab8 to your computer and use it in GitHub Desktop.
Save CodeMaster7000/9384860f99a9e58a1a0653e9eccb6ab8 to your computer and use it in GitHub Desktop.
A Python graph coded with matplotlib to visualise a sine wave.
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-np.pi,np.pi,100)
y = np.sin(x)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.spines['left'].set_position('center')
ax.spines['bottom'].set_position('center')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plt.plot(x,y, 'b-')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment