Plot a function you want - with Python 😃
Running with python demo.py
will open two windows, one with function plot, and another with interactive console.
In interactive console:
(InteractiveConsole)
>>> def f(x):
... return x**2
...
>>> setFunction(f) # set the function to f(x) = x^2
>>> setFunction(lambda x: x**2) # a one-liner version
The plotGraph.py
contains the essential plotting functions.
Open the plot window, start the interacting thread.
import plotGraph
plotGraph.startPlot()
Update the function to be plotted.
(InteractiveConsole)
>>> setFunction(lambda x: x**3) # f(x) = x^3
>>>
>>> import math
>>> setFunction(lambda x: math.sqrt(x), domain=(0, 100)) # f(x) = x^(1/2) with domain [0, 100)
>>> setFunction(lambda x: math.sin(x), precision=1.0) # f(x) = sin(x), sampled with step 1.0
Set the viewing rectangle.
(InteractiveConsole)
>>> import math
>>> setFunction(lambda x: math.sin(x)) # f(x) = sin(x)
>>> viewRect(xlim=(-math.pi, math.pi), ylim=(-1.0, 1.0)) # set the XY limits
{'xlim': (-3.141592653589793, 3.141592653589793), 'ylim': (-1.0, 1.0)}
For more details, refer to plotGraph.py
or help(plotGraph)
.
This project is licensed under the terms of MIT License.