Exemple #1
0
def colors(epsoutfile):        
    c = pyx.canvas.canvas()          # canvas for the whole drawing
    x = [0.0, 1.0]
    
    # first plot, with colors 'color11'
    g1 = pyxgraph(xlimits=(0 ,1), ylimits=(-1, 11),
                  xticks=(0, 1, 1),yticks=(0, 10, 1),
                  ylabel='color11', key=None, colors="color11", width=8)
    for i in xrange(11):
        g1.pyxplot((x, [i, i]), style="l", lt=0, lw=5, color=i)           
    c.insert(g1)

    # second plot below, with colors 'grey10'
    # The important difference is, that ypos is adjusted by the height of
	# the first plot.
    g2 = pyxgraph(width=8, ypos=g1.ypos-1.2*g1.height,
                  xlimits=(0, 1), xticks=(0, 1, 1),
                  ylimits=(-1, 5), yticks=(0, 4, 1),
                  ylabel='grey5', key=None, colors="grey5")
    for i in xrange(5):
        g2.pyxplot((x, [i, i]), style="l", lt=0, lw=5, color=i)        
    c.insert(g2)
    
    # third plot below, with colors 'rainbow'
    g3=pyxgraph(width=8, ypos=g2.ypos-1.2*g2.height,
                xlimits=(0, 1), xticks=(0, 1, 1),
                ylimits=(-1, 11), yticks=(0, 10, 1),
                ylabel='rainbow', key=None, colors="rainbow")
    for i in xrange(11):
        g3.pyxplot((x, [i, i]), style="l", lt=0, lw=5, color=i)        
    c.insert(g3)
    
    pyxsave(c, epsoutfile)
Exemple #2
0
def axes10(epsoutfile):
    """Different painter"""
    # longer red outside xticks:
    paint0 = pyx.graph.axis.painter.regular(innerticklength=None,
        outerticklength=pyx.graph.axis.painter.ticklength.long,
        tickattrs=[pyx.color.rgb.red, pyx.style.linewidth.thick])
    # longer blue inside xticks:
    paint1 = pyx.graph.axis.painter.linked(
        innerticklength=pyx.graph.axis.painter.ticklength.long,
        tickattrs=[pyx.color.rgb.blue, pyx.style.linewidth.thick])
    # longer dark green insside xticks:
    paint2 = pyx.graph.axis.painter.linked(
        innerticklength=pyx.graph.axis.painter.ticklength.LOng,
        tickattrs=[pyx.color.rgb(0.0, 0.0, 0.8), pyx.style.linewidth.thick])
    # longer dark green outside xticks:
    paint3 = pyx.graph.axis.painter.linked(innerticklength=None,
        outerticklength=pyx.graph.axis.painter.ticklength.long,
        tickattrs=[pyx.color.rgb(0.0, 0.0, 0.6), pyx.style.linewidth.thick])

    c = pyx.canvas.canvas()
    
    g1l = pyxgraph(width=5, xlimits=(0.0, 10.0), ylimits=(None, 2), key=False)
    g1l.pyxplot("y(x)=sin(x)", style="l")
    c.insert(g1l)

    g1r=pyxgraph(width=5, xpos=g1l.xpos+1.3*g1l.width,
                 xlimits=(0.0, 10.0), ylimits=(None, 2), key=False,
                 xpaint=paint0, x2paint=paint1)
    g1r.pyxplot("y(x)=sin(x)", style="l")
    g1r.pyxlabel((0.5, 0.8), "x: outside; x2: inside")
    c.insert(g1r)

    g2l=pyxgraph(width=5, ypos=g1l.ypos-1.4*g1l.height,
                 xlimits=(0.0, 10.0), ylimits=(None, 2), key=False,
                 ypaint=paint0, x2paint=paint1)
    g2l.pyxplot("y(x)=sin(x)", style="l")
    g2l.pyxlabel((0.5, 0.8), "y: outside; x2: inside")
    c.insert(g2l)

    g2r=pyxgraph(width=5,
                 xpos=g1l.xpos+1.3*g1l.width, ypos=g1l.ypos-1.4*g1l.height,
                 xlimits=(0.0, 10.0), ylimits=(None, 2), key=False,
                 xpaint=paint0, ypaint=paint0, x2paint=paint3, y2paint=paint2)
    g2r.pyxplot("y(x)=sin(x)", style="l")
    g2r.pyxlabel((0.5, 0.8), "x, y: out; x2: out, y2: in")
    c.insert(g2r)

    pyxsave(c, epsoutfile)
Exemple #3
0
def make_arrows(epsoutfile):
    g=pyxgraph(xlimits=(0.0, 10.0), key="bl")      
    g.pyxplot("y(x)=sin(x)", style="p", title=None)

    DarkGreen = pyx.color.rgb(0.0,0.4,0.0)
    DarkBlue = pyx.color.rgb(0.0,0.0,0.4)
    ArrowColor = pyx.color.rgb( 0.45882353,  0.85882353,  0.49411765)
    xm,ym=g.pos(4.0, 0.25)
    g.stroke(pyx.path.path(pyx.path.arc(xm,ym,2.2,0,180)),
                     [pyx.style.linewidth(0.35), pyx.deco.barrow.LARGe,
                      DarkGreen])

    xm,ym=g.pos(6.0, -0.25)
    arc2 = pyx.path.path(pyx.path.arc(xm,ym,2.2,0,170))
    # use a transformation to scale a path in y direction:
    trans = pyx.trafo.trafo()
    g.stroke(arc2.transformed(trans.scaled(1.0, 0.5)),
             [pyx.style.linewidth(0.35), pyx.deco.barrow.LARGe, DarkBlue])


    xl, yl =  g.pos(2.0, 0.1)
    xm1, ym1 =  g.pos(3.0, 0.5)
    xm2, ym2 =  g.pos(5.0, 0.5)
    xr, yr =  g.pos(6.0, 0.1)
    
    g.stroke(pyx.path.curve(xl, yl, xm1, ym1,xm2, ym2, xr, yr),
                     [pyx.style.linewidth(0.35), pyx.deco.barrow.LARGe,
                      ArrowColor, #pyx.style.linewidth.THin,
                      #pyx.deco.stroked([pyx.color.palette.Rainbow])
                      pyx.deco.stroked([pyx.color.rgb.green])
                      ])

    g.pyxsave(epsoutfile)
def matplotlib_pyx(epsoutfile):
    mpl_file = os.path.split(epsoutfile)[0]+"_tmp.png"
    Xs, Ys = matplotlib_plot(mpl_file)
    #Xs, Ys = 6, 6
    g = pyxgraph(width=2*Xs, height=2*Ys,
                 xlimits=(-2.0, 2.0), ylimits=(-2.0, 2.0)) 
    g.pyxplot("y(x)=sin(x)", style="p")


    # It seems the following comment is not correct! (Fortunately):
    #
    # We also need the `Image`, the Python Image Library (PIL),
    # to ensure that no `Flate` encoded images will end up
    # in the resulting postscript because this is a Postscript
    # Level 3 printer feature (and not all available printers eat that level).

    # However, for a different reason:
    # We also need the `Image`, the Python Image Library (PIL),
    # because newer versions of matplotlib cannot write jpg files,
    # but pyx (via g.pyxbitmap) either needs a jpg or a PIL image.
    # So we open using the PIL and use that in g.pyxbitmap.
    import Image
    im = Image.open(mpl_file)
    g.pyxbitmap(im)
    # This would be shorter, but does not work:
    #g.pyxbitmap(mpl_file)
    g.pyxsave(epsoutfile)
def filled_regions(epsoutfile):
    x = arange(0.0, 10.0, 0.1)
    phi = arange(0.0, 2.0*pi, 0.1)
    x_circ = cos(phi)-1.5
    y_circ = sin(phi)-1.0

    x_ell = 1.5*cos(phi)+1.0
    y_ell = 0.5*sin(phi)+0.5

    g=pyxgraph(xlabel=r"$x$", ylabel=r"$y$", xlimits=(-3.0, 3.0),
               ylimits=(-4.0, 4.0), key=False)      
    g.pyxplot((x, -sin(x)-1.0), style="p", title=None)  # we need at least one plot!!
                                                   # even if invisible
    p1 = convert_to_path(g, x_circ, y_circ)
    g.stroke(p1, [pyx.deco.filled([pyx.color.rgb(0.8, 0.8, 0.8)])])

    p2 = convert_to_path(g, x_ell, y_ell)
    g.stroke(p2, [pyx.deco.stroked([pyx.color.rgb(0.8, 0.2, 0.0)]),
                 pyx.style.linewidth(0.35),
                 pyx.deco.filled([pyx.color.rgb(0.8, 0.8, 0.8)]),
                 ])

    # a more funny shape
    p3 = convert_to_path(g, phi/2.0/pi*x_ell-2.4, 3*y_ell+0.5)
    g.fill(p3, [pyx.deco.filled([pyx.color.rgb(0.2, 0.8, 0.2)]),
                 ])

    g.pyxsave(epsoutfile)
Exemple #6
0
def axes_example7(epsoutfile):
    g=pyxgraph(xlimits=(0.0, 2.0*pi), key="bl", xaxistype="pi", ylabel="$y$",
               backgroundattrs=[pyx.deco.filled(
                                      [pyx.color.rgb(0.9, 0.9, 1.0)])])
    g.pyxplot("y(x)=sin(x)", title=r"$\sin(x)$", style="l")
    g.pyxplot("y(x)=cos(x)", title=r"$\cos(x)$", style="l", lw=2, dl=3)
    g.pyxsave(epsoutfile)
Exemple #7
0
def axes_example6(epsoutfile):
    g=pyxgraph(xlimits=(0.0, 8.0), xticks=(0.0, 8.0, 4.0), 
               ylimits=(0.0, 100.0),
               x2ticks=False, y2ticks=False
               )
    g.pyxplot(("test_data2.dat",1,2), title=r"$x^2$", style="l", color=2, lw=3)
    g.pyxsave(epsoutfile)
Exemple #8
0
def axes_example11(epsoutfile):
    g=pyxgraph(xlimits=(-1.0, 7.0), ylimits=(-2.0,4.0), key=False,
               xticks=False, yticks=False)

    # if everything is ok, the sin extends over the full y axis
    g.pyxplot("y(x)=1.0+3*sin(x)")
    g.pyxsave(epsoutfile)
Exemple #9
0
def axes_example1(epsoutfile):
    g = pyxgraph(yaxistype="log", xlimits=(0, 10), ylimits=(10 ** -5, 10 ** 5), key="br")
    g.pyxplot(("test_data2.dat", 1, 2), title=r"$x^2$")
    g.pyxplot(("test_data2.dat", 1, 3), title=r"$x^4$")
    g.pyxplot(("test_data2.dat", 1, 4), title=r"$\exp(x)$")
    g.pyxplot("x(y)=y*y", title=r"$\sqrt{x}$")
    g.dodata()  # draw data first and then the border on top
    g.pyxsave(epsoutfile)
Exemple #10
0
def colorbars(epsoutfile):
    x = (arange(50.0)-25)/2.0
    y = (arange(50.0)-25)/2.0
    r = sqrt(x[:,NewAxis]**2+y**2)
    z = 5.0*cos(r)  

    colmap = ColMapper.ColorMapper("yellow-red", exponent=0.55, brightness=0.5)
    lut = colmap.generate_lut()

    c = pyx.canvas.canvas()
    g = pyxgraph(xlimits=(min(x), max(x)), ylimits=(min(y), max(y)),
                 width=6, height=6)
    g.pyxplot("y(x)=sin(x)", style="p")  # FIXME: can't do empty plots!
    g.pyxplotarray(z, colmap=lut)
    c.insert(g)

    minz = minvalue=min(ravel(z))
    maxz = maxvalue=max(ravel(z))

    # --- vertical bars
    dist = 1.2
    for orientation, position in [("vertical", "right"),
                                  ("vertical", "middle"),
                                  ("vertical2", "middle")]:
        cb = pyxcolorbar(lut=lut, frame=g,
                         pos=(dist, 0),
                         orientation = orientation,
                         position = position,
                         minvalue = minz, maxvalue=maxz)
        # add a short note on the style:
        txt = orientation[0]
        if "2" in orientation:
            txt += "2"
        txt += ", "+position[0]            
        cb.pyxlabel( (0.0, 1.3), txt, style=[pyx.text.halign.left])

        c.insert(cb)
        dist = dist + 0.5

    # horizontal ones:
    dist = -0.3
    for orientation, position in [("horizontal", "middle"),
                                  ("horizontal2", "middle")]:
        cb = pyxcolorbar(lut=lut, frame=g, pos=(0.0, dist),
                         orientation = orientation,
                         position = position,
                         minvalue = minz, maxvalue=maxz)
        # add a short note on the style:
        txt = orientation[0]
        if "2" in orientation:
            txt += "2"
        txt += ", "+position[0]            
        cb.pyxlabel( (1.3, 0.5), txt, style=[pyx.text.halign.left])

        c.insert(cb)
        dist = dist - 0.3
    
    pyxsave(c, epsoutfile)
Exemple #11
0
def axes8(epsoutfile):
    """Plot of Chebychev polynomials"""    
    g = pyxgraph(key=pyx.graph.key.key(pos="mr",hinside=0),
                 ylimits=(-1.1, 1.1), xlabel="$x$", ylabel="$T_j(x)$")
    x = arange(-1.0,1.01,0.01)
    for i in xrange(5):
        g.pyxplot((x, special.chebyt(i)(x)),
                  title="$T_%d(x)$" % i, style="l", dl=2, color=0)
    g.pyxsave(epsoutfile)
Exemple #12
0
def axes9(epsoutfile):
    """Different axis label positions"""
    c = pyx.canvas.canvas()
    
    g1 = pyxgraph(xlimits=(0.0, 10.0), key="bl")
    g1.pyxplot("y(x)=sin(x)")
    g1.pyx_xlabel("x")
    g1.pyx_ylabel("y")
    c.insert(g1)
    
    g2=pyxgraph(ypos=g1.ypos-1.2*g1.height, xlimits=(0.0, 0.1), key=False)
    g2.pyxplot("y(x)=sin(x)")
    g2.pyx_xlabel("x", xpos=0.7, yshift=-0.5)
    g2.pyx_ylabel("y", ypos=0.8, xshift=-2.0)
    g2.pyxlabel((0.4, 0.8), "Shifting labels in x and y, respectively")
    c.insert(g2)

    pyxsave(c, epsoutfile)
Exemple #13
0
def axes_example3(epsoutfile):
    key = pyx.graph.key.key(pos="tl", textattrs=[pyx.text.size(-3)])
    g=pyxgraph(xlimits=(0.0, 8.0), xticks=(0.0, 8.0, 4.0), xticksformat="%5.4f",
               ylimits=(0.0, 100.0), yticks=(0.0, 100.0, 25.0), key=key)
    g.pyxplot(("test_data2.dat", 1, 2), title=r"$x^2$")
    g.pyxplot(("test_data2.dat", 1, 3), title=r"$x^4$")
    g.pyxplot(("test_data2.dat", 1, 4), title=r"$\exp(x)$")
    g.pyxplot(("test_data2.dat", 1, "75*$5"), title=r"$75\exp(-x)$")
    g.pyxsave(epsoutfile)
Exemple #14
0
def errorbars(epsoutfile):
    g = pyxgraph(xlimits=(0,1), ylimits=(0,1), key="br")
    
    x = [0.1, 0.3, 0.5, 0.7, 0.9]
    mean = [0.05, 0.1, 0.2, 0.4, 0.8]
    error = [0.05, 0.07, 0.17, 0.15, 0.15]
    
    g.pyxerrorbar(x, mean, error, pt=17, ps=1.0, lt=0, lw=1, title="data")
    
    g.pyxsave(epsoutfile)
def simple2(epsoutfile):
    c = pyx.canvas.canvas()          # canvas for the whole drawing

    # first plot
    g1 = pyxgraph(xlimits=(0.0, 10.0), key="bl")
    g1.pyxplot("y(x)=sin(x)", style="p")    
    c.insert(g1)

    # second plot below
	# Caution: Adjust ypos by the height of the first plot. 
    g2=pyxgraph(ypos=g1.ypos-1.2*g1.height, xlimits=(0.0, 5.0), key="bl")
    g2.pyxplot("y(x)=10**6*cos(x)", style="l", lw=3, color=(1.0, 0.5, 0.0))
    c.insert(g2)

    g1.pyxlabel((8,-0.5), "label1 in graphcoords", graphcoords=True)
    g2.pyxlabel((2,200000),"label2 in graphcoords",  [pyx.text.halign.left],
                graphcoords=True)

    pyxsave(c, epsoutfile)
Exemple #16
0
def axes_example1(epsoutfile):
    g=pyxgraph(yaxistype=axis.axis.linear(min=0, max=10e-4),
               xlimits=(0, 100), key="br")
               
    x = arange(100)
    y = x**2/10e6
               
    g.pyxplot((x, y), title=r"$x^2/10^{-6}$")
    g.dodata()               # draw data first and then the border on top
    g.pyxsave(epsoutfile)
Exemple #17
0
def axes_example2(epsoutfile):
    g=pyxgraph(yaxistype="log", ylimits=(10**-5, 10**5),
               xaxistype="log", xlimits=(10**-2, 10),
               dashlength=4)
    g.pyxplot(("test_data2.dat", 1, 2), title=r"$x^2$", style="l", lw=3)
    g.pyxplot(("test_data2.dat", 1, 3), title=r"$x^4$", style="l", lw=3)
    g.pyxplot(("test_data2.dat", 1, 4), title=r"$\exp(x)$", style="l", lw=3)
    g.pyxplot(("test_data2.dat", 1, 5, dict(skiphead=5, skiptail=20)),
              title=r"$\exp(-x)$ (with skip)", style="l", lw=3, dl=0.5)
    g.pyxsave(epsoutfile)
Exemple #18
0
def plot_histogram(epsoutfile, x):
    
    g = pyxgraph(width=6, height=6,
                 key=None,
                 xlabel="x", 
                 xlimits=(min(x),max(x))
                )
    g.pyxplothist(x, Nbins = 100, bin_range=(min(x),max(x)), bars=0)
    
    g.pyxsave(epsoutfile)
Exemple #19
0
def axes_example12(epsoutfile):
    #from pyx.graph.axis import tick

    g=pyxgraph(xlimits=(0.01, 10.0), ylimits=(-2.0,2.0), key=False,
               xaxistype="log",
               xticks=(0.01, 10.0, 10, 10),
               yticks=(-2.0, 2.0, 1.0, 5))

    # if everything is ok, the sin extends over the full y axis
    g.pyxplot("y(x)=2*sin(x)", style="l", color="blue")
    g.pyxsave(epsoutfile)
Exemple #20
0
def array_example1(epsoutfile):
    x = (arange(100.0)-50)/25.0
    y = (arange(100.0)-50)/25.0
    # Important: z[y, x] -- y first!
    z = 5.0*sin(2*x[NewAxis, :]) + 3.0*cos(3*y[:, NewAxis])

    g=pyxgraph(xlimits=(min(x), max(x)), ylimits=(min(y), max(y)),
               width=6, height=6, key=False)
    g.pyxplotcontour(z, x, y, levels=15, colors='map',
                     colmap=ColMapper.ColorMapper("pm3d",
                                                exponent=1.0, brightness=0.2))
    g.pyxsave(epsoutfile)
Exemple #21
0
def axes_example16(epsoutfile):
    c = pyx.canvas.canvas()

    g1 = pyxgraph(xlimits=(0.0, 2.0*pi), key="bl", xaxistype="linear", ylabel="$y$",
               xticks=(0, 2*pi, 1))
               
    g1.pyxplot("y(x)=sin(x)", title=r"$\sin(x)$", style="l")
    g1.pyxplot("y(x)=cos(x)", title=r"$\cos(x)$", style="l", lw=2, dl=3)
    
    c.insert(g1)
    
    g2 = pyxgraph(xlimits=(0.0, 2.0), key="bl", xaxistype=pyx.graph.axis.linkedaxis(g1.axes["x"]), 
               ylabel="$y$",
               xticks=False, ypos=+6.5)
                                      
    g2.pyxplot("y(x)=sin(x)", title=r"$\sin(x)$", style="l")
    g2.pyxplot("y(x)=cos(x)", title=r"$\cos(x)$", style="l", lw=2, dl=3)
    
    c.insert(g2)
    
    pyxsave(c, epsoutfile)
Exemple #22
0
def symbols(epsoutfile):
    y = arange(5)/5.0+0.1
    
    g = pyxgraph(xlimits=(-1, 25), ylimits=(0, 1),           
                 xticks=(0, 24, 2), yticks=(0, 1, 1), key=None) 
    
    for i in xrange(25):
        x = zeros(5)+i   
        g.pyxplot((x, y), style="p", pt=i)   # ``pt=i`` can be omitted
                                             # (then the next symbol is choosen
                                             #  automatically)
    g.pyxsave(epsoutfile)
Exemple #23
0
def simple3(epsoutfile):
    c = pyx.canvas.canvas()          # canvas for the whole drawing

    # first plot
    g1=pyxgraph(xlimits=(0.0, 10.0))
    g1.pyxplot("y(x)=(x-5.0)**2", style="p")
    c.insert(g1)

    # second plot as inset
    g2=pyxgraph(width=g1.width/2.5, height=g1.height/2.5,
                xpos=g1.xpos+0.4*g1.width, ypos=g1.ypos+0.5*g1.height,
                xlimits=(0.0,5.0),
                axesdist=0.15*0.8*pyx.unit.v_cm)
    g2.pyxplot("y(x)=10**6*cos(x)", style="l", color=(0.0, 0.2, 1.0))

    # Modify the distance of the axes to the labels.
    # Note that in this example only the first has
    # to be modified as all the other seem to be the
    # same instance. Thus successively applying the factor is not good.
    # Just accessing the first element in the list of axes does the job
    for ax_key in g2.axes.keys()[0]:
        ax = g2.axes[ax_key]
        print ax.axis.painter.labeldist
        ax.axis.painter.labeldist = 0.5*ax.axis.painter.labeldist
        
    save_xscale = pyx.unit.scale["x"]
    save_vscale = pyx.unit.scale["v"]
    #save_wscale = pyx.unit.scale["w"]
    print pyx.unit.scale
    pyx.unit.set(xscale=0.5*save_xscale)
    pyx.unit.set(vscale=0.5*save_vscale)
    #pyx.unit.set(wscale=0.15*save_wscale)  # effect????
    g2.doaxes()
    g2.dokey()
    c.insert(g2)
    pyx.unit.set(xscale=save_xscale)            
    pyx.unit.set(vscale=save_vscale)            
    #pyx.unit.set(wscale=save_wscale)            

    pyxsave(c, epsoutfile)
Exemple #24
0
def array_example1(epsoutfile):
    x = (arange(50.0)-25)/2.0
    y = (arange(50.0)-25)/2.0
    r = sqrt(x[:,NewAxis]**2+y**2)
    z = 5.0*sin(r)  

    g=pyxgraph(xlimits=(min(x), max(x)), ylimits=(min(y), max(y)),
               width=6, height=6, key=False)
    # WARNING: if key is not specified to be False, one gets a weird
    # error ....
    #g.pyxplot("y(x)=sin(x)", style="p")  # FIXME: can't do empty plots!
    g.pyxplotarray(z, colmap=ColMapper.ColorMapper("yellow-red",
                                                exponent=0.55, brightness=0.5))
    g.pyxsave(epsoutfile)
Exemple #25
0
def array_example2(epsoutfile):
    x = (arange(100.0)-50)/25.0
    y = (arange(100.0)-50)/25.0
    # Important: z[y, x] -- y first!
    z = 5.0*sin(2*x[NewAxis, :]) + 3.0*cos(3*y[:, NewAxis])

    colmap = ColMapper.ColorMapper("yellow-red", invert=1, exponent=0.55,
                                   brightness=0.5)
    #lut = colmap.generate_lut()

#    c = pyx.canvas.canvas()
    g = pyxgraph(xlimits=(min(x), max(x)), ylimits=(min(y), max(y)),
                 width=6, height=6, key=False)
    g.pyxplotarray(z[::-1,:], colmap=colmap)
    g.pyxplotcontour(z, x, y, colors='color', color='black', labels=True)
   
    pyxsave(g, epsoutfile)
def styles_example(epsoutfile):
    mystyles = ['.', '-', '-"', '_ ', '6_1 ', '- . ']
    count = len(mystyles)
    x1 = 0.8*arange(2)

    g = pyxgraph(xlimits=(-0.1, 1.1), xticks=(0, 1, 1),
                 ylimits=(-1, count), yticks=(0, count-1, 1),
                 ylabel='linestyles', key=None, width=8)

    for i in xrange(count):
        y = ones(2)+i-1 
        g.pyxplot((x1, y), style="l", lw=1, color=0, lt=mystyles[i])
        g.pyxlabel((0.85, i),
                   '\\tt{'+repr(mystyles[i]).replace('_','\\_')+'}',
                   style=[pyx.text.halign.left], graphcoords=True)
        
    g.pyxsave(epsoutfile)
Exemple #27
0
def simple1(epsoutfile):
    x = arange(0.0, 10.0, 0.1)

    g=pyxgraph(title="A first plot ;-)",  # one graph (essentially a
               xlabel=r"$x$",             #    pyx.grapxy instance)
               ylabel=r"$f(x)$",
               key="bl")     
    g.pyxplot("y(x)=sin(x)", style="p", title=None)
    
    g.pyxplot((x, cos(x)))
    g.pyxplot("test_data.dat", style="l", lt=0,
                              lw=3, title="Optional title")
    g.pyxplot(("test_data.dat",1,4), title=False)
    g.pyxplot(("test_data.dat",1, "$4+$5*$1/4"), style="lp", pt=6,
              lw=0.1, ps=0.8, title="blurb2",
              color='cyan', linecolor='purple')
    g.pyxsave(epsoutfile)
Exemple #28
0
def styles_example(epsoutfile):
    x1 = 0.25*arange(2)
    x2 = x1+0.5-0.125
    x3 = x1+1.0-0.25
    
    g = pyxgraph(xlimits=(-0.1, 1.1), xticks=(0, 1, 1),
                 ylimits=(-1, 12), yticks=(0, 11, 1),
                 ylabel='linestyles', key=None, width=8)
    for i in xrange(12):
        y = ones(2)+i-1 
        g.pyxplot((x1, y), style="l", lw=1, color=0, lt=i)
        g.pyxplot((x2, y), style="l", lw=3, color=0, lt=i)
        g.pyxplot((x3, y), style="l", lw=1, color=0, lt=i, dl=4)
    g.pyxlabel( (0.125,1.05), "lw=1", [pyx.text.halign.center])
    g.pyxlabel( (0.5,1.05), "lw=3", [pyx.text.halign.center])
    g.pyxlabel( (0.875,1.05), "lw=1, dl=4", [pyx.text.halign.center])

    g.pyxsave(epsoutfile)
Exemple #29
0
def axes_example4(epsoutfile):
    g = pyxgraph(
        xticks=False,
        yticks=False,
        # the xlimits and ylimits are needed so that it is
        # known on which axes the function will be plotted.
        xlimits=(0.0, 8.0),
        ylimits=(0.0, 100.0),
        x2axistype="linear",
        y2axistype="linear",
        x2limits=(0.0, 8.0),
        x2ticks=(0.0, 8.0, 4.0),
        y2limits=(0.0, 100.0),
        y2ticks=(0.0, 100.0, 25.0),
        x2texter=None,
        y2texter=None,
    )
    g.pyxplot("y(x)=x**2", title=r"$x^2$", style="l", linetype=4)
    g.pyxsave(epsoutfile)
def sans_serif_fonts2(epsoutfile):
    g=pyxgraph(width=12,
               xlimits=(0, 10), key=False,
               xlabel=r"$h_{\text{heff}}^{-1}$")
    g.pyxplot(("test_data2.dat", 1, 3), title=r"$x^4$")
    g.pyxplot(("test_data2.dat", 1, 4), title=r"$\exp(x)$")

    g.pyxlabel((0.025, 0.9), r"\small ABCDEFGHIJKLMNOPQRSTUVWXYZ",
               [pyx.text.halign.left])
    g.pyxlabel((0.025, 0.8), r"\small$ABCDEFGHIJKLMNOPQRSTUVWXYZ$",
               [pyx.text.halign.left])
    g.pyxlabel((0.025, 0.7), r"\small abcdefghijklmnopqrstuvwxyz",
               [pyx.text.halign.left])
    g.pyxlabel((0.025, 0.6), r"\small $abcdefghijklmnopqrstuvwxyz$",
               [pyx.text.halign.left])

    g.pyxlabel((0.025, 0.4), r"\small $\alpha\beta\gamma\delta\epsilon\rho\phi\varphi\mu\nu$",
               [pyx.text.halign.left])
    g.pyxsave(epsoutfile)