Curve is not continuous in matplotlib for python 3

Viewed 666

This is my program to graph functions and it works great. There is only one problem.

while 1==1:
    import numpy as np
    import matplotlib.pyplot as plt
    print("FUNCTION GRAPHER")
    def graph(formula,domain):
        x = np.array(domain)
        y = eval(formula)
        plt.plot(x, y)
        plt.show()
    def sin(x):
        return np.sin(x)
    def cos(x):
        return np.cos(x)
    def tan(x):
        return np.tan(x)
    def csc(x):
        return 1/(np.sin(x))
    def sec(x):
        return 1/(np.cos(x))
    def cot(x):
        return 1/(np.tan(x))
    formula=input("Function: y=")
    domainmin=int(input("Min X Value: "))
    domainmax=int(input("Max X Value: "))
    graph(formula, range(domainmin,domainmax))
    print("DONE!")

When I try a non-linear function, it is not "curvy":

FUNCTION GRAPHER
Function: y=sin(x**2)
Min X Value: 0
Max X Value: 32

I cannot post a pic because I don't have enough reputation yet... but its just really spiky, and the points are only plotted every 1 unit.

1 Answers
Related