Skip to content

Instantly share code, notes, and snippets.

@rishi93
Last active November 6, 2018 08:41
Show Gist options
  • Select an option

  • Save rishi93/7d20441a9f160b422417adaa649ed3d5 to your computer and use it in GitHub Desktop.

Select an option

Save rishi93/7d20441a9f160b422417adaa649ed3d5 to your computer and use it in GitHub Desktop.
Simple 2D plot in Matplotlib
import numpy as np
import matplotlib.pyplot as plt
# Create the figure and the axes
fig = plt.figure()
ax = fig.add_subplot(111, title = 'Sine wave')
# Prepare the datapoints
x = np.linspace(0, 2*np.pi, 100)
y = np.sin(x)
# Plot the data points
plt.plot(x, y)
# Display the plot
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment