Skip to content

Instantly share code, notes, and snippets.

@tomr-stargazer
Created November 25, 2013 04:38
Show Gist options
  • Save tomr-stargazer/7636445 to your computer and use it in GitHub Desktop.
Save tomr-stargazer/7636445 to your computer and use it in GitHub Desktop.
Demo of how to do cool colorful folded
import numpy as np
import matplotlib.pyplot as plt
# Let's make some "dummy" data -- a time coordinate "x" and corresponding data "y".
x = np.arange(500)
y = np.sin(x/20.) + x/250.
period= 20 * 2*np.pi
# And then fold it on the period.
modulated = (x % period)/period
fig = plt.figure()
# Subplot makes two plots
plt.subplot(2,1,1)
# Scatter makes a scatterplot; when we set the "c=" keyword it colors in the points based on the array you give it.
plt.scatter(x,y, c=x)
plt.subplot(2,1,2)
plt.scatter(modulated, y, c=x)
plt.colorbar()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment