Created
August 11, 2020 00:26
-
-
Save ThatCoolCoder/bd9e26140d2bda5f1d96f201298da667 to your computer and use it in GitHub Desktop.
Plot an equation (inputted as a string) on a graph. Go from start value to end value, incrementing by increment. An example equation would be 'sin(x)'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from math import * | |
def plotEquation(equation, start=0, end=10, increment=0.1): | |
inputs = [] | |
results = [] | |
i = start | |
while i <= end: | |
inputs.append(i) | |
x = i | |
results.append(eval(equation)) | |
i += increment | |
plt.plot(inputs, results) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment