Ejemplo n.º 1
0
 def __init__(
     self,
     min=None,
     max=None,
     reverse=0,
     divisor=None,
     title=None,
     painter=painter.regular(),
     texter=texter.mixed(),
     linkpainter=painter.linked(),
     density=1,
     maxworse=2,
     manualticks=[],
     fallbackrange=None,
 ):
     if min is not None and max is not None and min > max:
         min, max, reverse = max, min, not reverse
     self.min = min
     self.max = max
     self.reverse = reverse
     self.divisor = divisor
     self.title = title
     self.painter = painter
     self.texter = texter
     self.linkpainter = linkpainter
     self.density = density
     self.maxworse = maxworse
     self.manualticks = self.checkfraclist(manualticks)
     self.fallbackrange = fallbackrange
Ejemplo n.º 2
0
 def __init__(self,
              min=None,
              max=None,
              reverse=0,
              divisor=None,
              title=None,
              painter=painter.regular(),
              texter=texter.default(),
              linkpainter=painter.linked(),
              density=1,
              maxworse=2,
              manualticks=[],
              fallbackrange=None):
     if min is not None and max is not None and min > max:
         min, max, reverse = max, min, not reverse
     self.min = min
     self.max = max
     self.reverse = reverse
     self.divisor = divisor
     self.title = title
     self.painter = painter
     self.texter = texter
     self.linkpainter = linkpainter
     self.density = density
     self.maxworse = maxworse
     self.manualticks = self.checkfraclist(manualticks)
     self.fallbackrange = fallbackrange
Ejemplo n.º 3
0
    data = [[-1.0, 1.0], [0.0, 0.0], [1.0, 1.0]]

    x2 = fitpoly(data, 2)
    x4 = fitpoly(data, 4)
    x8 = fitpoly(data, 8)

    try:
        from pyx import *
        from pyx.graph.axis import painter, tick

        text.set(mode="latex")

        p = painter.regular(
            basepathattrs=[deco.earrow.normal],
            titlepos=0.95,
            titledist=-0.3,
            titledirection=None,
            outerticklength=graph.axis.painter.ticklength.normal,
        )

        g = graph.graphxy(width=8,
                          xaxisat=0,
                          yaxisat=0,
                          x=graph.axis.linear(title="$t$",
                                              min=-2.9,
                                              max=2.9,
                                              painter=p),
                          y=graph.axis.linear(
                              min=-0.05,
                              max=1.9,
                              manualticks=[
Ejemplo n.º 4
0
import math
from pyx import *
from pyx.graph.axis.parter import linear as linparter
from pyx.graph.axis.painter import regular, ticklength, rotatetext
from pyx.graph.axis.texter import rational, exponential
from pyx.graph.axis.axis import lin, pathaxis

c = canvas.canvas()
lintest = {"title": "axis title", "min": 0, "max": 1, "parter": linparter(["0.25", "0.1/0.8"])}
c.insert(pathaxis(path.path(path.moveto(0, 0), path.lineto(0, 8)),
                        lin(**lintest),
                        direction=-1))
c.insert(pathaxis(path.path(path.moveto(1, 0), path.lineto(1, 8)),
                        lin(**lintest)))
c.insert(pathaxis(path.path(path.moveto(5, 0), path.lineto(5, 8)),
                        lin(painter=regular(labelattrs=[trafo.rotate(45)], titleattrs=[trafo.rotate(45)]), **lintest),
                        direction=-1))
c.insert(pathaxis(path.path(path.moveto(8, 0), path.lineto(8, 8)),
                        lin(painter=regular(labelattrs=[trafo.rotate(45), text.halign.right], titleattrs=[trafo.rotate(-45)]), **lintest),
                        direction=-1))
c.insert(pathaxis(path.path(path.moveto(11, 0), path.lineto(11, 8)),
                        lin(painter=regular(tickattrs=[color.rgb.red], innerticklength=0, outerticklength=ticklength.normal), **lintest),
                        direction=-1))
c.insert(pathaxis(path.path(path.moveto(12, 0), path.lineto(12, 8)),
                        lin(painter=regular(tickattrs=[attr.changelist([None, color.rgb.green])]), **lintest)))
c.insert(pathaxis(path.path(path.moveto(16, 0), path.lineto(16, 8)),
                        lin(texter=exponential(), **lintest),
                        direction=-1))
c.insert(pathaxis(path.path(path.moveto(18, 0), path.lineto(18, 8)),
                        lin(texter=rational(), **lintest),
                        direction=-1))
Ejemplo n.º 5
0
def fakebarpainter(*args, **kwargs):
    """Return a PyX linear axis painter that behaves like a bar axis painter."""
    return painter.regular(innerticklength=0, outerticklength=0)
Ejemplo n.º 6
0
	#print type(x)
	#x = numpy.array
	#print x[1], type(x[1])
	

except IndexError, e:
	pass #print 



#sys.exit()


text.preamble(r"\parindent=0pt")

mypainter = regular(basepathattrs=[earrow.normal], titlepos=0.5, 
	labeldist="0.3", titledist="0.2")

g = graph.graphxy(height=10, width=15,
                  x=graph.axis.linear(title=r"Time Delay ($\mu$s)", density = 3, painter = mypainter),
                  y=graph.axis.linear(title="TDC Counts", density =2,
painter = mypainter))


g.plot(graph.data.file("data.dat", x=1, y=2), 
# Define symbol & color
	styles=[graph.style.symbol(graph.style.symbol.plus, size=0.4, symbolattrs=[color.palette.Rainbow])])


#******************
#Linear regression linefit
gradient, intercept, r_value, p_value, std_err = stats.linregress(x,y)
Ejemplo n.º 7
0
import math
from pyx import *
from pyx.graph.axis.parter import linear as linparter
from pyx.graph.axis.painter import regular, ticklength, rotatetext
from pyx.graph.axis.texter import rational, default
from pyx.graph.axis.axis import lin, pathaxis

c = canvas.canvas()
lintest = {"title": "axis title", "min": 0, "max": 1, "parter": linparter(["0.25", "0.1/0.8"])}
c.insert(pathaxis(path.path(path.moveto(0, 0), path.lineto(0, 8)),
                        lin(**lintest),
                        direction=-1))
c.insert(pathaxis(path.path(path.moveto(1, 0), path.lineto(1, 8)),
                        lin(**lintest)))
c.insert(pathaxis(path.path(path.moveto(5, 0), path.lineto(5, 8)),
                        lin(painter=regular(labelattrs=[trafo.rotate(45)], titleattrs=[trafo.rotate(45)]), **lintest),
                        direction=-1))
c.insert(pathaxis(path.path(path.moveto(8, 0), path.lineto(8, 8)),
                        lin(painter=regular(labelattrs=[trafo.rotate(45), text.halign.right], titleattrs=[trafo.rotate(-45)]), **lintest),
                        direction=-1))
c.insert(pathaxis(path.path(path.moveto(11, 0), path.lineto(11, 8)),
                        lin(painter=regular(tickattrs=[color.rgb.red], innerticklength=0, outerticklength=ticklength.normal), **lintest),
                        direction=-1))
c.insert(pathaxis(path.path(path.moveto(12, 0), path.lineto(12, 8)),
                        lin(painter=regular(tickattrs=[attr.changelist([None, color.rgb.green])]), **lintest)))
c.insert(pathaxis(path.path(path.moveto(16, 0), path.lineto(16, 8)),
                        lin(texter=default(), **lintest),
                        direction=-1))
c.insert(pathaxis(path.path(path.moveto(18, 0), path.lineto(18, 8)),
                        lin(texter=rational(), **lintest),
                        direction=-1))
Ejemplo n.º 8
0
# contributed by Francisco Borges

from pyx import *
from pyx.graph import graphxy, data, axis
from pyx.graph.axis import painter, tick
from pyx.deco import earrow

range = 2.5

p = painter.regular(basepathattrs=[earrow.normal],
                    titlepos=0.95,
                    outerticklength=painter.ticklength.normal,
                    titledist=-0.3,
                    titledirection=None)  # horizontal text

g = graphxy(
    width=10,
    xaxisat=0,
    yaxisat=0,
    x=axis.linear(
        title="$x$",
        min=-range,
        max=+range,
        painter=p,
        # suppress some ticks by overwriting ...
        manualticks=[tick.tick(0, None, None),
                     tick.tick(range, None, None)]),
    y=axis.linear(
        title=r"$x\sin(x^2)$",
        painter=p,
        manualticks=[tick.tick(0, None, None),
Ejemplo n.º 9
0
# contributed by Sigmund Kohler

from math import pi, cos
from pyx import *
from pyx.deco import barrow, earrow
from pyx.style import linewidth, linestyle
from pyx.graph import graphxy
from pyx.graph.axis import linear
from pyx.graph.axis.painter import regular
from pyx.graph.style import line
from pyx.graph.data import function

mypainter = regular(basepathattrs=[earrow.normal], titlepos=1)
def mycos(x): return -cos(x)+.10*x

g = graphxy(height=5, x2=None, y2=None,
            x=linear(min=-2.5*pi, max=3.3*pi, parter=None,
                      painter=mypainter, title=r"$\delta\phi$"),
            y=linear(min=-2.3, max=2, painter=None))
g.plot(function("y(x)=mycos(x)", context=locals()),
       [line(lineattrs=[linewidth.Thick])])
g.finish()

x1, y1 = g.pos(-pi+.1, mycos(-pi+.1))
x2, y2 = g.pos(-.1, mycos(-.1))
x3, y3 = g.pos(pi+.1, mycos(pi+.1))

g.stroke(path.line(x1-.5, y1, x1+.5, y1), [linestyle.dashed])
g.stroke(path.line(x1-.5, y3, x3+.5, y3), [linestyle.dashed])
g.stroke(path.line(x2-.5, y2, x3+.5, y2), [linestyle.dashed])
g.stroke(path.line(x1, y1, x1, y3), [barrow.normal, earrow.normal])
Ejemplo n.º 10
0
lineproperties = [
    graph.style.line([
        style.linestyle.solid, style.linewidth.thick, style.linejoin.round,
        color.rgb(0.2, 0, 0.8)
    ])
]

text.set(engine=text.LatexEngine)
text.preamble(r'''\usepackage[sfdefault,lining,scaled=.85]{FiraSans}
                  \usepackage{newtxsf}''')
unit.set(vscale=1.2, wscale=1.3, xscale=1.3)

c = canvas.canvas()

painter_x = painter.regular(basepathattrs=[deco.earrow],
                            titlepos=1,
                            titledist=-0.35,
                            titleattrs=[text.halign.right])

painter_y = painter.regular(basepathattrs=[deco.earrow],
                            titlepos=1.03,
                            titledist=0.15,
                            titleattrs=[text.valign.top],
                            titledirection=None)

g1 = c.insert(
    graphxy(width=5,
            height=2,
            xaxisat=0,
            yaxisat=0,
            x=axis.linear(title="$x$",
                          min=0,
Ejemplo n.º 11
0
             [ 0.0, 0.0],
             [ 1.0, 1.0] ]
       
    x2 = fitpoly(data, 2)
    x4 = fitpoly(data, 4)
    x8 = fitpoly(data, 8)

    try:
        from pyx import *            
        from pyx.graph.axis import painter, tick

        text.set(mode="latex")

        p = painter.regular(basepathattrs=[deco.earrow.normal],
                            titlepos=0.95, 
                            titledist=-0.3,
                            titledirection=None,
                            outerticklength=graph.axis.painter.ticklength.normal,
                            )

        g = graph.graphxy(width=8, xaxisat=0, yaxisat=0,
                          x=graph.axis.linear(title="$t$", min=-2.9, max=2.9,
                                              painter=p),
                          y=graph.axis.linear(min=-0.05, max=1.9,
                                              manualticks=[tick.tick(0, None, None),
                                                           tick.tick(0.5, label=r"$\frac{1}{2}$", ticklevel=0),
                                                           tick.tick(1.5, label=r"$\frac{3}{2}$", ticklevel=0),
                                                           ],
                                              painter=p))
    
        def f(t,x): return t, sum([ x[i]*(t**i) for i in range(len(x)) ]) 
Ejemplo n.º 12
0
# contributed by Francisco Borges

from pyx import *
from pyx.graph import graphxy, data, axis
from pyx.graph.axis import painter, tick
from pyx.deco import earrow

range = 2.5

p = painter.regular(basepathattrs=[earrow.normal], titlepos=0.95,
                    outerticklength=painter.ticklength.normal,
                    titledist=-0.3, titledirection=None) # horizontal text

g = graphxy(width=10, xaxisat=0, yaxisat=0,
            x=axis.linear(title="$x$", min=-range, max=+range, painter=p,
                          # suppress some ticks by overwriting ...
                          manualticks=[tick.tick(0, None, None),
                                       tick.tick(range, None, None)]),
            y=axis.linear(title=r"$x\sin(x^2)$", painter=p,
                          manualticks=[tick.tick(0, None, None),
                                       tick.tick(3, None, None)]))

g.plot(data.function("y(x)=x*sin(x**2)"),
       # Line style is set before symbol style -> symbols will be draw
       # above the line.
       [graph.style.line([style.linewidth.Thin, style.linestyle.solid]),
        graph.style.symbol(graph.style.symbol.circle, size=0.1,
                           symbolattrs=[deco.filled([color.rgb.green]),
                                        deco.stroked([color.rgb.red])])])

# manually typeset "0" near the origin