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,x2-x1,y2-y1),[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


      

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to