Skip to content

Latest commit

 

History

History
52 lines (44 loc) · 1.39 KB

File metadata and controls

52 lines (44 loc) · 1.39 KB

plotGraph

Plot a function you want - with Python 😃

Usage

Running with python demo.py will open two windows, one with function plot, and another with interactive console.

Interacting

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

Advanced Usage

The plotGraph.py contains the essential plotting functions.

startPlot

Open the plot window, start the interacting thread.

import plotGraph
plotGraph.startPlot()

setFunction(func, domain, precision)

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

viewRect(xlim, ylim)

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).

License

This project is licensed under the terms of MIT License.