Fixed layout

This commit is contained in:
Michele Guerini Rocco 2014-01-14 20:26:11 +01:00
parent 2c65f8c59d
commit 1c4cad6754

View File

@ -3,58 +3,64 @@
## Application to plot functions in python 3. ## Application to plot functions in python 3.
### Info ### Info
An application to plot a function (points, piecewise or normal) using turtle graphics. An application to plot a function (points, piecewise or normal) using turtle graphics.
The application is structured in two modules: "graph.py" contains classes and functions for drawing while "plotter.py" is the GUI (tkinter) module that facilitates and speeds up the use. The application is structured in two modules: "graph.py" contains classes and functions for drawing while "plotter.py" is the GUI (tkinter) module that facilitates and speeds up the use.
graph.py is independent and can be used even without the graphical interface. graph.py is independent and can be used even without the graphical interface.
You can save the plot in svg format via [canvas2svg] (Link: http://wm.ite.pl/proj/canvas2svg/index.html). You can save the plot in svg format via [canvas2svg] (Link: http://wm.ite.pl/proj/canvas2svg/index.html).
### Instructions ### Instructions
graph.py: **graph.py**:
* Import the module graph.py. * Import the module graph.py.
`import graph` `import graph`
* Create a Cartesian plane instantiate an object "graph" by providing the lengths of the axes. * Create a Cartesian plane instantiate an object "graph" by providing the lengths of the axes.
`plane = graph.graph(20,20)` `plane = graph.graph(20,20)`
* Draw a function using the method draws providing a function, the interval in the domain, and color. * Draw a function using the method draws providing a function, the interval in the domain, and color.
`plane.plot (lambda x: x**2-2*x+1, -10, 10, "#92182b")` `plane.plot (lambda x: x**2-2*x+1, -10, 10, "#92182b")`
* Clean the graph. * Clean the graph.
`plane.clean()` `plane.clean()`
`Graph()` is subclass of turtle.Pen so you can use all the methods inherited. `Graph()` is subclass of turtle.Pen so you can use all the methods inherited.
plotter.py: **plotter.py**:
Normal: **Normal**:
* Enter the function in the first text box. Between the variable and the coefficients a * is not necessary. * Enter the function in the first text box. Between the variable and the coefficients a * is not necessary.
  Use `^` for exponentiation and `|` for the absolute value |f(x)|.   Use `^` for exponentiation and `|` for the absolute value |f(x)|.
eg |cos(x)*1/2x| `eg |cos(x)*1/2x|`
* Enter the range of the function to print in the second box.
eg -10, 10
* Enter the color in the third box. A string with the name of the color, a tuple that contains RGB numbers, #RGB color in hex.
eg #a1a1a1
Defined by points: * Enter the range of the function to print in the second box.
`eg -10, 10`
* Insert the points of the function into a tuple of the form (x1, y2), (x2, y2). * Enter the color in the third box. A string with the name of the color, a tuple that contains RGB numbers, #RGB color in hex.
eg (0,0), (1,2), (2,4), (3,-3) `eg #a1a1a1`
* Enter the range of the function to print the second box.
eg -10,10
* Enter the color in the third box. A string with the name of the color, a tuple that contains RGB numbers, #RGB color in hex.
eg #a1a1a1
Piecewise: **Points**:
* Insert the points of the function into a tuple of the form (x1, y2), (x2, y2).
`eg (0,0), (1,2), (2,4), (3,-3)`
* Enter the range of the function to print the second box.
`eg -10,10`
* Enter the color in the third box. A string with the name of the color, a tuple that contains RGB numbers, #RGB color in hex.
`eg #a1a1a1`
**Piecewise**:
* Enter the traits in a tuple type [f1(x), (range)], [f2(x), (range)].
`eg [(-x), (-100,0)], [(x), (0,100)]`
* Enter the range of the function to print the second box.
`eg -10.10`
* Enter the traits in a tuple type [f1(x), (range)], [f2(x), (range)].
eg [ (-x), (-100,0)], [(x), (0,100)]
* Enter the range of the function to print the second box.
eg -10.10
* Enter the color in the third box. A string with the name of the color, a tuple that contains RGB numbers or #RGB color in hex. * Enter the color in the third box. A string with the name of the color, a tuple that contains RGB numbers or #RGB color in hex.
eg #a1a1a1 `eg #a1a1a1`
You can use all the functions and constants defined in `math` module. You can use all the functions and constants defined in `math` module.
### License ### License
Dual licensed under the MIT and GPL licenses: Dual licensed under the MIT and GPL licenses:
http://www.opensource.org/licenses/mit-license.php http://www.opensource.org/licenses/mit-license.php
http://www.gnu.org/licenses/gpl.html http://www.gnu.org/licenses/gpl.html