Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4. plt.rcParams["figure.figsize"] = [10, 8]
  5. plt.style.use('fivethirtyeight')
  6. %matplotlib inline
  7.  
  8. df = pd.DataFrame({'flux': [7953.371, 9045.019, 10052.73, 11174.9, 12468.98, 13973.44, 15765.74, 17721.66, 19667.59, 21671.05, 23839.87, 26193.85, 28826.92, 31833.04, 35277.45, 39350.62, 44119.84, 49781.21, 56399.18, 64513.93, 75960.82, 92307.63, 116218.9, 148417.9, 197342.0, 280455.2, 368527.9, 480157.0, 672086.2, 1253551.0],
  9. 'gc': [0.23848699999999998, 0.197701, 0.18892799999999998, 0.180912, 0.18326900000000002, 0.186448, 0.22009, 0.26702, 0.310159, 0.36151500000000003, 0.408945, 0.435596, 0.43973100000000004, 0.44741800000000004, 0.445114, 0.434199, 0.42946899999999993, 0.39339, 0.373621, 0.364333, 0.34575300000000003, 0.320202, 0.272527, 0.21973800000000002, 0.18654300000000001, 0.131162, 0.062214, 0.049783999999999995, 0.047236, 0.059118],
  10. 'gm': [0.23848699999999998, 0.197701, 0.18892799999999998, 0.180912, 0.18326900000000002, 0.186448, 0.22009, 0.26702, 0.310159, 0.36151500000000003, 0.408945, 0.435596, 0.43973100000000004, 0.44741800000000004, 0.445114, 0.434199, 0.42946899999999993, 0.39339, 0.373621, 0.364333, 0.34575300000000003, 0.320202, 0.272527, 0.21973800000000002, 0.18654300000000001, 0.131162, 0.062214, 0.049783999999999995, 0.047236, 0.059118]})
  11. print(df.head())
  12. flux gc gm
  13. 0 7953.371 0.238487 0.238487
  14. 1 9045.019 0.197701 0.197701
  15. 2 10052.730 0.188928 0.188928
  16. 3 11174.900 0.180912 0.180912
  17. 4 12468.980 0.183269 0.183269
  18.  
  19. # my attempt
  20. x = df['flux'].values
  21. y = df['gm'].values
  22.  
  23. degree = 3
  24. z = np.polyfit(x,y,degree)
  25. p = np.poly1d(z)
  26. xp = np.linspace(x.min(), x.max(), 1000)
  27. plt.plot(x, y, '.', xp, p(xp), '-')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement