Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jamespeterschinner/1b101f8ab212cc1c25a353738f5925c8 to your computer and use it in GitHub Desktop.
Save jamespeterschinner/1b101f8ab212cc1c25a353738f5925c8 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
from statistics import mean
def chunks(l, n=2):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i + n]
# Data to plot
result = [63, 1, 69, 29, 48, 56, 64, 16, 19, 51]
temperature = [4, 25, 37, 55, 70]
# Calculate mean of 2 samples
data = {
str(temp): mean(result)
for temp, result in zip(temperature, chunks(result))
}
plt.bar(data.keys(), data.values())
plt.show()
@jamespeterschinner
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment