update upload data
[PyX.git] / examples / graphs / function.txt
blobce3333d094bd847b8ef6b383c7fba6adbcad7b9d
1 Plotting a function graph
3 Here, we explain how to plot the graph of a real-valued mathematical function of
4 a single real parameter. ...
6 As in the previous example, we first create a `graph.graphxy` instance passing
7 the width as argument. We then pass a `graph.data.function` instance to the
8 `plot` method of the graph. As first argument, we pass the function in the form
9 "y(x) = f(x)". Here, the left-hand side of the equation defines which parameter
10 is independent (here: `x`) and which one is dependent (here: `y`). We also need
11 to inform PyX about the range of the independent variable. This is done by passing
12 the parameters `min` and `max`.
14 ! In order to increase the resolution of the function graph, you can use the
15 parameter `points` of the `graph.data.function` class to increase the number of
16 sampling points from its default value of `100`.
18 Note that the default graph style for function data is `graph.style.line` synce
19 PyX assumes a continuous x-range. 
21 ! You only need to pass the `min` and `max` parameters to the
22 `graph.data.function` class, if PyX cannot figure out an axis range by itself.
23 Thus, an alternative way to achieve the above result would look like
24     g = graph.graphxy(width=8, x=graph.axis.linear(min=-15, max=15))
25     g.plot(graph.data.function("y(x)=sin(x)/x"))
26 Here, we explicitely define an x-axis range by passing an appropriate
27 argument to the `x` parameter of the `graph.graphxy` class.
29 ! For PyX it does not matter, whether you plot a function of a parameter `x` or
30 a parameter `y`. Thus, you may as well write
31     g.plot(graph.data.function("x(y)=sin(y)/y", min=-15, max=15))
32 to obtain a plot where the y-coordinate is the independent one.