Skip to content

Instantly share code, notes, and snippets.

@cal687
Created May 14, 2020 14:18
Show Gist options
  • Save cal687/371776454d15655233b4d91fc279b2d7 to your computer and use it in GitHub Desktop.
Save cal687/371776454d15655233b4d91fc279b2d7 to your computer and use it in GitHub Desktop.
#We will create wo histograms, each displaying the frequency of an occurrence each day of the year
#(either flights or flower blooms).
#You will use the in_bloom variable to find a count of the number of flowers that start blooming each day of the year.
#You will use the flights variable to find a count of the number of flights that occur each day of the year.
# import codecademylib3
import codecademylib3
import numpy as np
from matplotlib import pyplot as plt
# load in data
in_bloom = np.loadtxt(open("in-bloom.csv"), delimiter=",")
flights = np.loadtxt(open("flights.csv"), delimiter=",")
# Plot the histograms
plt.figure(1)
plt.subplot(211)
plt.hist(flights, range=(0,365), bins=365)
plt.xlabel('Days of the year')
plt.ylabel('Number of flights')
plt.title('Frequency of flights')
plt.subplot(212)
plt.hist(in_bloom, range=(0,365), bins=365)
plt.title("Flower Blooms and Flights by Day")
plt.ylabel("Bloom Count")
plt.xlabel("Day of the Year")
plt.show()
@cal687
Copy link
Author

cal687 commented May 14, 2020

Screen Shot 2020-05-14 at 10 17 46 AM

Screen Shot 2020-05-14 at 10 14 58 AM

if someone said they wanted to visit Acadia while there weren’t many people there, but while flowers were blooming, when would you recommend? Based on these histograms, I would propose they go between days 250 and 300, which is the Fall. The flight’s histogram shows fewer flights between these days, while the flowers histogram indicates there should be a number of flowers in bloom during this time.

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