Skip to content

Instantly share code, notes, and snippets.

@phsantiago
Last active May 11, 2022 03:51
Show Gist options
  • Save phsantiago/cc3576257abe1242bdeadd8046a680df to your computer and use it in GitHub Desktop.
Save phsantiago/cc3576257abe1242bdeadd8046a680df to your computer and use it in GitHub Desktop.
Python charts with numpy
import numpy as np
from matplotlib import pyplot as plt
concentrationCurve = [100,50,25,12.5,6.25,3.125,0]
opticalDensityCurve = [0.7755,0.3205,0.1325,0.061,0.038,0.029,0.026]
concentrationSamples = [19.1,28.05,44.44,59.38,68.67,74.27,91.33]
opticalDensitySample = [0.1065,0.1585,0.268,0.384,0.464,0.515,0.684]
concentration = concentrationCurve + concentrationSamples
opticalDensity = opticalDensityCurve + opticalDensitySample
plt.scatter(concentrationCurve, opticalDensityCurve, c='lightblue')
plt.scatter(concentrationSamples, opticalDensitySample, c='darkblue')
#polynomial fit with degree = 2
model = np.poly1d(np.polyfit(concentration, opticalDensity, 2))
plt.xlabel ('SNAP concentration (µM)')
plt.ylabel ('Optical Density (OD)')
plt.title ('Curva de concentração do SNAP e pontos de amostragem')
#add fitted polynomial line to scatterplot
polyline = np.linspace(1, 125, 50)
#plt.scatter(concentration, od)
#plt.plot(polyline, model(polyline))
plt.show()
print("model:")
print(model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment