Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from numpy import *
- import matplotlib.pyplot as plt
- import math
- import pylab
- from matplotlib import mlab
- print("Строитель графиков")
- f = input ('f(x)=')
- code = """
- def func (x):
- return %s
- """ % f
- exec(code)
- xmin = -20.0
- xmax = 20
- dx = 0.01
- xlist = mlab.frange (xmin, xmax, dx)
- ylist = [func (x) for x in xlist]
- plt.axis([-20, 20, -20, 20])
- plt.xlabel('x')
- plt.ylabel('y')
- plt.title('График функции(x)')
- plt.grid(True)
- pylab.plot (xlist, ylist)
- pylab.show()
- code = """
- def func (x):
- return %s
- """ % f
- # -*- coding: utf-8 -*-
- import numexpr as ne
- import matplotlib.pyplot as plt
- from matplotlib import mlab
- plt.style.use('ggplot')
- xmin = -20.0
- xmax = 20
- dx = 0.01
- x = mlab.frange(xmin, xmax, dx)
- # f = input ('f(x)=')
- f = "x**2 * sin(x)"
- plt.plot(x, ne.evaluate(f), linewidth=1.5)
- plt.xlabel('x')
- plt.ylabel('y')
- plt.legend(['График функции: f(x) = {}'.format(f)])
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement