I suppose because I have things on digest mode it's a
little bit more difficult to respond directly.
Nevertheless, thanks a lot for your help Andre. It
just feels like the solution was too easy. : )
Even so, if anybody could tell me how to do fill
patterns, I would still be interested to hear.
Regards,
Daniel
 Dan Reinholz <xaenn@...> wrote:
> Hello all,
>
> I'm a bit new to pyx (I was previously a gnuplot
> user)
> and have been struggling with this problem for
> awhile.
>
>
> I'm working on generating some graphs for calculus,
> and I'm trying to illustrate the formal definition
> of
> the limit. In this I want to illustrate a box that
> shows which range of x values stays within the error
> tolerance. My code is:
>
> from pyx import *
> from pyx.graph import axis
>
> def f(x):
> return pow((x + 1),3) + 1
> a,b,c = 0.5874,1.28943,1
>
> ticksx = [graph.axis.tick.tick(c, label="$x_0$")]
> ticksy = [graph.axis.tick.tick(f(a), label="$L 
> \\varepsilon$"),
> graph.axis.tick.tick(f(c), label="$L$"),
> graph.axis.tick.tick(f(b), label="$L +
> \\varepsilon$")]
>
> g = graph.graphxy(width=8,
> x=axis.linear(min=0, max=1.5,
> title="$x$",manualticks=ticksx,parter=None),
>
>
y=axis.linear(title="$f(x)$",manualticks=ticksy,parter=None))
>
> d=g.plot(graph.data.function("y(x)=(x+1)**3 +
> 1",points=1000))
>
> g.finish()
>
> x1,y1 = g.pos(a,f(a))
> x2,y2 = g.pos(b,f(b))
>
g.stroke(path.rect(x1,y1,x2x1,y2y1),[deco.filled([color.gray(0.8)])
> ])
> g.stroke(g.ygridpath(f(a)),
> [style.linestyle.dashed,style.linewidth.Thin])
> g.stroke(g.xgridpath(a),
> [style.linestyle.dashed,style.linewidth.Thin])
>
> g.stroke(g.ygridpath(f(b)),
> [style.linestyle.dashed,style.linewidth.Thin])
> g.stroke(g.xgridpath(b),
> [style.linestyle.dashed,style.linewidth.Thin])
>
> g.stroke(g.ygridpath(f(c)), [style.linewidth.Thin])
> g.stroke(g.xgridpath(c), [style.linewidth.Thin])
>
> g.writeEPSfile("limit_definition")
>
> which works fine except for that I want the box to
> be
> behind the graph rather than on top of it. I've
> thought of a few solutions, but haven't been able to
> successfully implement any of them (I would actually
> love to know how to do all of them, but I don't want
> to be too greedy).
>
> 1. Knowing how to plot the filled rectangle beneath
> the graph would solve the problem.
>
> 2. Knowing how to make the fill color transparent.
>
> 3. Knowing how to use a different pattern for the
> fill
> so that the graph of the function still shows
> beneath
> it.
>
> If anyone could please show me how to modify my
> existing code or otherwise point me in the right
> direction, it would be extremely helpful. I am not
> very familiar with python, so I imagine syntax is
> part
> of my problem. Many thanks for any help that can be
> offered.
>
> Regards,
> Daniel
>
>
>
>
