def array34(arange, hlshape=None):
    c = canvas.canvas()
    if hlshape is None:
        c.text(2, 3.3, 'shape=(3, 4)', [text.halign.center])
    else:
        c.text(2, 3.3, 'shape=%s' % repr(hlshape), [text.halign.center])
    if hlshape is not None:
        if len(hlshape) == 1:
            hlshape = (1, hlshape[0])
    if arange:
        gridcolor = color.grey(0)
    else:
        gridcolor = color.grey(0.5)
    if hlshape is None:
        arange = True
    elif (hlshape[0] in (1, 3)) and (hlshape[1] in (1, 4)):
        arange = False
    else:
        arange = None
    drawgrid(c, 4, 3, 0, gridcolor, arange=arange)
    if hlshape is not None:
        c.stroke(path.rect(0, 3, hlshape[1], -hlshape[0]),
                 [deco.filled([color.rgb(1, 0.8, 0.4)])])
        drawgrid(c, hlshape[1], hlshape[0], 3-hlshape[0], arange=False)
    if arange is None:
        alertcolor = color.rgb(0.6, 0, 0)
        c.stroke(path.line(0, 0, 4, 3), [alertcolor, style.linewidth.Thick])
        c.stroke(path.line(0, 3, 4, 0), [alertcolor, style.linewidth.Thick])
    return c
Ejemplo n.º 2
0
def array34(arange, hlshape=None):
    c = canvas.canvas()
    if hlshape is None:
        c.text(2, 3.3, 'shape=(3, 4)', [text.halign.center])
    else:
        c.text(2, 3.3, 'shape=%s' % repr(hlshape), [text.halign.center])
    if hlshape is not None:
        if len(hlshape) == 1:
            hlshape = (1, hlshape[0])
    if arange:
        gridcolor = color.grey(0)
    else:
        gridcolor = color.grey(0.5)
    if hlshape is None:
        arange = True
    elif (hlshape[0] in (1, 3)) and (hlshape[1] in (1, 4)):
        arange = False
    else:
        arange = None
    drawgrid(c, 4, 3, 0, gridcolor, arange=arange)
    if hlshape is not None:
        c.stroke(path.rect(0, 3, hlshape[1], -hlshape[0]),
                 [deco.filled([color.rgb(1, 0.8, 0.4)])])
        drawgrid(c, hlshape[1], hlshape[0], 3 - hlshape[0], arange=False)
    if arange is None:
        alertcolor = color.rgb(0.6, 0, 0)
        c.stroke(path.line(0, 0, 4, 3), [alertcolor, style.linewidth.Thick])
        c.stroke(path.line(0, 3, 4, 0), [alertcolor, style.linewidth.Thick])
    return c
def arraygraphics(a,
                  idxstr,
                  title=True,
                  xscale=1.0,
                  fgcolor=color.grey(1),
                  bgcolor=color.hsb(0.9, 1, 0.5)):
    """create a graphical representation of a two-dimensional array
    
    a         array containing the data to be shown
    slicestr  string defining the slice to be highlighted
    xscale    PyX scaling for text
    fgcolor   color of highlighted data
    bgcolor   color of highlighted cells

    """
    assert a.ndim == 2
    n0, n1 = a.shape
    highlighted = np.zeros_like(a, dtype=bool)
    exec("highlighted{} = True".format(idxstr))
    unit.set(xscale=xscale)
    text.set(text.LatexRunner)
    text.preamble(
        r'\usepackage[sfdefault,scaled=.85,lining]{FiraSans}\usepackage{newtxsf}'
    )
    c = canvas.canvas()
    for ny, nx in zip(*np.nonzero(highlighted)):
        c.fill(path.rect(nx, n0 - ny, 1, -1), [bgcolor])
    c.stroke(path.rect(0, 0, n1, n0))
    for nx in range(1, n1):
        c.stroke(path.line(nx, 0, nx, n0))
    for ny in range(1, n0):
        c.stroke(path.line(0, ny, n1, ny))
    textcentered = [text.halign.center, text.valign.middle]
    textcentered_highlighted = textcentered + [fgcolor]
    for nx in range(n1):
        for ny in range(n0):
            if highlighted[ny, nx]:
                textattrs = textcentered_highlighted
            else:
                textattrs = textcentered
            c.text(nx + 0.5, n0 - ny - 0.5, a[ny, nx], textattrs)
    if title:
        textcolor = bgcolor
    else:
        textcolor = color.grey(1)
    titlestr = r"\Large a" + idxstr.replace('%', '\%')
    c.text(0.5 * n1, n0 + 0.4, titlestr, [text.halign.center, textcolor])
    return c
def arraygraphics(a, idxstr, title=True, xscale=1.0,
               fgcolor=color.grey(1), bgcolor=color.hsb(0.9, 1, 0.5)):
    """create a graphical representation of a two-dimensional array
    
    a         array containing the data to be shown
    slicestr  string defining the slice to be highlighted
    xscale    PyX scaling for text
    fgcolor   color of highlighted data
    bgcolor   color of highlighted cells

    """
    assert a.ndim == 2
    n0, n1 = a.shape
    highlighted = np.zeros_like(a, dtype=bool)
    exec("highlighted{} = True".format(idxstr))
    unit.set(xscale=xscale)
    text.set(text.LatexRunner)
    text.preamble(r'\usepackage[sfdefault,scaled=.85,lining]{FiraSans}\usepackage{newtxsf}')
    c = canvas.canvas()
    for ny, nx in zip(*np.nonzero(highlighted)):
        c.fill(path.rect(nx, n0-ny, 1, -1), [bgcolor])
    c.stroke(path.rect(0, 0, n1, n0))
    for nx in range(1, n1):
        c.stroke(path.line(nx, 0, nx, n0))
    for ny in range(1, n0):
        c.stroke(path.line(0, ny, n1, ny))
    textcentered = [text.halign.center, text.valign.middle]
    textcentered_highlighted = textcentered+[fgcolor]
    for nx in range(n1):
        for ny in range(n0):
            if highlighted[ny, nx]:
                textattrs = textcentered_highlighted
            else:
                textattrs = textcentered
            c.text(nx+0.5, n0-ny-0.5, a[ny, nx], textattrs)
    if title:
        textcolor = bgcolor
    else:
        textcolor = color.grey(1)
    titlestr = r"\Large a"+idxstr.replace('%', '\%')
    c.text(0.5*n1, n0+0.4, titlestr, [text.halign.center, textcolor])
    return c
Ejemplo n.º 5
0
def drawgrid(c, nxcells, nycells, yoff, gridcolor=color.grey(0), arange=None):
    c.stroke(path.rect(0, yoff, nxcells, nycells), [gridcolor])
    for nx in range(nxcells-1):
        c.stroke(path.line(nx+1, yoff, nx+1, yoff+nycells), [gridcolor])
    for ny in range(nycells-1):
        c.stroke(path.line(0, yoff+ny+1, nxcells, yoff+ny+1), [gridcolor])
    entry = '1'
    if arange is not None:
        for nx in range(nxcells):
            for ny in range(nycells):
                if arange:
                    entry = str(4*ny+nx)
                c.text(nx+0.5, 2.5-ny, entry,
                       [text.halign.center, text.valign.middle, gridcolor])
Ejemplo n.º 6
0
def array(shape):
    baseshape = (3, 4)
    bgcolor = color.grey(0.5)
    c = canvas.canvas()
    c.text(baseshape[1] / 2, baseshape[0] + 0.3, 'shape=%s' % repr(shape),
           [text.halign.center])
    if len(shape) == 1:
        shape = (1, shape[0])
    assert len(shape) == 2
    c.stroke(path.rect(0, 0, baseshape[1], baseshape[0]), [bgcolor])
    for nx in range(1, baseshape[1]):
        c.stroke(path.line(nx, 0, nx, baseshape[0]), [bgcolor])
    for ny in range(1, baseshape[0]):
        c.stroke(path.line(0, ny, baseshape[1], ny), [bgcolor])
    if not (shape == baseshape):
        c.fill(path.rect(0, baseshape[0], shape[1], -shape[0]),
               [color.rgb(1, 0.8, 0.4)])
        if shape[0] in (1, baseshape[0]) and shape[1] in (1, baseshape[1]):
            for nx in range(baseshape[1]):
                for ny in range(baseshape[0]):
                    c.text(
                        nx + 0.5, baseshape[0] - ny - 0.5,
                        str(baseshape[1] * min(ny, shape[0] - 1) +
                            min(nx, shape[1] - 1) + 1),
                        [text.halign.center, text.valign.middle, bgcolor])
        else:
            alertcolor = color.rgb(0.6, 0, 0)
            c.stroke(path.line(0, 0, baseshape[1], baseshape[0]),
                     [alertcolor, style.linewidth.Thick])
            c.stroke(path.line(0, baseshape[0], baseshape[1], 0),
                     [alertcolor, style.linewidth.Thick])
    else:
        for nx in range(baseshape[1]):
            for ny in range(baseshape[0]):
                c.text(nx + 0.5, baseshape[0] - ny - 0.5,
                       str(baseshape[1] * ny + nx + 1),
                       [text.halign.center, text.valign.middle])
    c.stroke(path.rect(0, baseshape[0], shape[1], -shape[0]))
    for nx in range(1, shape[1]):
        c.stroke(path.line(nx, baseshape[0], nx, baseshape[0] - shape[0]))
    for ny in range(1, shape[0]):
        c.stroke(path.line(0, ny, shape[1], ny))
    if not (shape == baseshape):
        for nx in range(shape[1]):
            for ny in range(shape[0]):
                c.text(nx + 0.5, baseshape[0] - ny - 0.5,
                       str(baseshape[1] * ny + nx + 1),
                       [text.halign.center, text.valign.middle])
    return c
Ejemplo n.º 7
0
def draw_config(name):
    c = canvas.canvas()
    config = configs[name]
    ysize = len(config)
    xsize = len(config[0])
    for nx in range(xsize):
        for ny in range(ysize):
            if config[ny][nx]:
                c.fill(path.rect(nx, ysize-ny, 1, -1))
    strokecolor = color.grey(0.6)
    c.stroke(path.rect(0, 0, xsize, ysize), [strokecolor])
    for nx in range(1, xsize):
        c.stroke(path.line(nx, 0, nx, ysize), [strokecolor])
    for ny in range(1, ysize):
        c.stroke(path.line(0, ny, xsize, ny), [strokecolor])
    return c
Ejemplo n.º 8
0
from pyx import color, deco, graph, style

with open('numba_parallel.dat') as fh:
    t_cpu = float(fh.readline().rstrip('\n').split()[1])
    t_parallel = [(1, t_cpu)]
    for _ in range(7):
        elems = fh.readline().rstrip('\n').split()
        t_parallel.append((int(elems[0]), float(elems[1])))
t_parallel = [(n, t_cpu / t) for n, t in t_parallel]

g = graph.graphxy(width=8,
                  x=graph.axis.linear(min=1, max=8, title="number of threads"),
                  y=graph.axis.linear(title="acceleration"))
g.plot(graph.data.points(t_parallel, x=1, y=2), [
    graph.style.line([]),
    graph.style.symbol(symbol=graph.style.symbol.circle,
                       size=0.1,
                       symbolattrs=[deco.filled([color.grey(1)])])
])
g.writePDFfile()
g.writeGSfile(device="png16m", resolution=600)
Ejemplo n.º 9
0
from math import atan, degrees
from pyx import canvas, color, path, style, text, unit

unit.set(xscale=0.8)
c = canvas.canvas()
c.fill(path.circle(0, 0, 0.1), [color.grey(0.5)])
c.fill(path.circle(2, 1, 0.1), [color.grey(0.5)])
c.stroke(path.line(0, 0, -1., -0.2),
         [style.linewidth.Thick, style.linestyle.dotted])
c.stroke(path.line(2, 1, 2.7, 1.7),
         [style.linewidth.Thick, style.linestyle.dotted])
c.stroke(path.line(0, 0, 2, 1), [style.linewidth.thick])
c.stroke(path.path(path.moveto(0, 0), path.lineto(2, 0), path.lineto(2, 1)))
c.text(0.5, 0.1, r'$\varphi$')
c.stroke(path.path(path.arc(0, 0, 0.8, 0, degrees(atan(0.5)))))
c.text(1, 0.6, r'$\ell=1$', [text.halign.right])
c.text(1, -0.1, r'$\cos(\varphi)$', [text.halign.center, text.valign.top])
c.text(2.1, 0.5, r'$\sin(\varphi)$', [text.valign.middle])
c.writeGSfile(device='pnggray', resolution=200)
Ejemplo n.º 10
0
boxwidth = 3
height = 4
qi = 0.2*boxwidth
qf = 0.7*boxwidth
linecolor1 = color.rgb(0.8, 0, 0)
linecolor2 = color.rgb(0, 0, 0.8)

text.set(engine=text.LatexEngine)
text.preamble(r'''\usepackage[sfdefault,scaled=.85]{FiraSans}
                  \usepackage{newtxsf}''')
unit.set(vscale=1.2, wscale=1.3, xscale=1.5)
c = canvas.canvas()
c.fill(path.rect(0, 0, boxwidth, height), [color.rgb(0.92, 1, 0.92)])
for n in range(-1, 4):
    c.stroke(path.line(n*boxwidth, 0, n*boxwidth, height),
             [style.linewidth.THick, color.grey(0.4)])
poslinestyle = (style.linestyle.dashed, style.linewidth.Thick)
for n in range(-1, 2):
    q = qf + 2*n*boxwidth
    c.stroke(path.line(q, 0, q, height), [*poslinestyle, linecolor1])
    c.stroke(path.line(q, height+1.1, q, height+1.5), [style.linewidth.thick])
for n in range(-1, 2):
    q = -qf + (2*n+2)*boxwidth
    c.stroke(path.line(q, 0, q, height), [*poslinestyle, linecolor2])
    c.stroke(path.line(q, height+0.1, q, height+0.5), [style.linewidth.thick])
for n in range(0, 2):
    c.stroke(path.line(-qf+2*n*boxwidth, height+0.3,
                       -qf+2*(n+1)*boxwidth, height+0.3),
             [style.linewidth.thick, deco.barrow, deco.earrow])
    c.text(-qf+(1+2*n)*boxwidth, height+0.4, '$2L$',
           [text.halign.center])
Ejemplo n.º 11
0
def draw_square(x, y, kante):
    c.stroke(path.rect(x, y, kante, kante),
             [style.linewidth.thick,
              deco.filled([color.grey(1)])])
Ejemplo n.º 12
0
unit.set(xscale=1.2, wscale=1.5)

frontplane = canvas.canvas()
backplane = canvas.canvas()
xcells = 4
ycells = 3
xshift = 0.8
yshift = 1.2
dist = 0.2
myred = color.rgb(0.8, 0, 0)
mygreen = color.rgb(0, 0.6, 0)
myblue = color.rgb(0, 0, 0.8)
for c, start in ((frontplane, 0), (backplane, xcells * ycells)):
    c.stroke(
        path.rect(0, 0, 4, 3),
        [deco.filled([color.grey(1), color.transparency(0.2)])])
    for x in range(1, xcells):
        c.stroke(path.line(x, 0, x, ycells))
    for y in range(1, ycells):
        c.stroke(path.line(0, y, xcells, y))
    for entry in range(xcells * ycells):
        x = entry % 4
        y = ycells - entry // 4
        c.text(x + 0.5, y - 0.5, str(start + entry),
               [text.halign.center, text.valign.middle])
c = canvas.canvas()
c.insert(backplane, [trafo.translate(xshift, yshift)])
for x, y in product((0, xcells), (0, ycells)):
    c.stroke(path.line(x, y, x + xshift, y + yshift))
c.insert(frontplane)
dx = -dist * yshift / sqrt(xshift**2 + yshift**2)
Ejemplo n.º 13
0
                  \usepackage{newtxsf}''')
unit.set(vscale=1.2, wscale=1.3, xscale=1.3)
c = canvas.canvas()
c.stroke(path.line(0, 0, width, 0), [deco.earrow])
c.text(width + 0.1, 0, '$t$', [text.valign.middle])
c.stroke(path.line(0, lowertick, 0, height), [deco.earrow])
c.text(0.2, height, '$q$', [text.valign.top])
n = 6
for nt in range(n + 1):
    t = nt * tmax / n
    c.stroke(path.line(t, 0, t, lowertick))
    c.stroke(path.line(t, 0, t, height - 0.26), [style.linestyle.dashed])
seed(424242)
positions = [(height - 0.3) * random() for _ in range(n - 1)]
positions.append(qf)
p = path.path(path.moveto(0, qi))
for nt, q in enumerate(positions):
    p.append(path.lineto((nt + 1) * tmax / n, q))
c.stroke(p, [style.linejoin.round, color.rgb(0.2, 0, 0.8)])
c.text(0, -0.55, '$0$', [text.halign.center])
c.text(3 * tmax / n, -0.55, '$n{-}1$', [text.halign.center])
c.text(4 * tmax / n, -0.55, '$n$', [text.halign.center])
c.text(tmax, -0.55, '$N$', [text.halign.center])
for x, y in ((0, qi), (tmax, qf)):
    c.fill(path.circle(x, y, 0.04),
           [color.grey(1), deco.stroked([color.grey(0)])])
c.text(-0.1, qi, r'$q_\text{i}$', [text.halign.right, text.valign.middle])
c.text(tmax + 0.1, qf, r'$q_\text{f}$', [text.valign.middle])
c.text(width - 0.2, height - 0.26, '$N={}$'.format(n), [text.valign.top])
c.writePDFfile()
Ejemplo n.º 14
0
from math import exp, expm1
from pyx import color, deco, graph, style, text, unit

text.set(text.LatexEngine)
mypainter = graph.axis.painter.regular(innerticklength=None,
                                       outerticklength=graph.axis.painter.ticklength.normal)
g = graph.graphxy(width=8,
                  x=graph.axis.log(title="$x$",
                                   painter=mypainter),
                  y=graph.axis.lin(title=r"$f(x)-1$",
                                   min=-1.1e-6,
                                   max=1.1e-6,
                                   painter=mypainter,
                                   parter=graph.axis.parter.lin(tickdists=[1e-6])),
                  key=graph.key.key(pos="tr")
                 )
g.plot(graph.data.function("y(x)=(exp(x)-1)/x-1", min=1e-10, max=1e-6,
                           title=r"\textsf{\big(exp(x)-1\big)/x}"),
       [graph.style.symbol(symbol=graph.style.symbol.circle,
                           size=0.15*unit.v_cm,
                           symbolattrs=[deco.filled([color.rgb(0.2, 0.2, 1)]),
                                        deco.stroked([color.grey(1)])])])
g.plot(graph.data.function("y(x)=expm1(x)/x-1", min=1e-10, max=1e-6,
                           title=r"\textsf{expm1(x)/x}",
                           context={"expm1": expm1}),
       [graph.style.line([color.rgb(1, 0.5, 0), style.linewidth.Thick])])
g.writeGSfile("expm1.png", resolution=300)
Ejemplo n.º 15
0

def draw_grid():
    c.stroke(path.rect(0, 0, 25, 2))
    for n in range(24):
        c.stroke(path.line(n + 1, 0, n + 1, 2))
    c.stroke(path.line(0, 1, 25, 1))


text.set(text.LatexRunner)
text.preamble(r'\usepackage{arev}\usepackage[T1]{fontenc}')
unit.set(xscale=1.2, wscale=2.5)

cgesamt = canvas.canvas()
c = canvas.canvas()
c.fill(path.rect(0, 1, 2, 1), [color.grey(0.7)])
c.text(0.5, 1.5, '0', [text.halign.center, text.valign.middle])
c.text(1.5, 1.5, '1', [text.halign.center, text.valign.middle])
basename = os.path.splitext(sys.argv[0])[0]
baseprimes = [0, 2, 3, 5, 7]
ncolor = len(baseprimes) - 1
cancelled = set([0, 1])
for nr, baseprime in enumerate(baseprimes):
    if nr == 0:
        for n in range(2, 50):
            x = n % 25
            y = 2 - (n // 25)
            c.text(x + 0.5, y - 0.5, str(n),
                   [text.halign.center, text.valign.middle])
    else:
        cancelled.add(baseprime)
Ejemplo n.º 16
0
        cval = c[nx * nlen + mx, ny * nlen + my]
        data.append((cval.real, cval.imag, partialdata[mx, my]))
    procdict[(nx, ny)] = procid
procids = set(procdict.values())
colors = [
    color.hsb(n / (len(procids) - 1) * 0.67, 1, 1) for n in range(len(procids))
]
proccolors = dict(zip(procids, colors))

text.set(text.LatexRunner)
text.preamble(r'\usepackage{arev}\usepackage[T1]{fontenc}')
g = graph.graphxy(width=8,
                  height=8,
                  x=graph.axis.lin(title=r'$\mathrm{Re}(c)$'),
                  y=graph.axis.lin(title=r'$\mathrm{Im}(c)$'))
g.plot(graph.data.points(data, x=1, y=2, color=3),
       [graph.style.density(keygraph=None)])

dx = (xmax - xmin) / n
dy = (ymax - ymin) / n
for k, v in procdict.items():
    nx, ny = k
    tilecolor = proccolors[v]
    xll, yll = g.pos(xmin + dx * nx, ymin + dy * ny)
    xur, yur = g.pos(xmin + dx * (nx + 1), ymin + dy * (ny + 1))
    g.fill(path.rect(xll, yll, xur - xll, yur - yll),
           [deco.stroked([color.grey(0)]), tilecolor,
            color.transparency(0.5)])
g.writePDFfile()
# convert to PNG with Gimp to keep transparency
Ejemplo n.º 17
0
def draw_square(x, y, kante):
    c.stroke(path.rect(x, y, kante, kante),
             [style.linewidth.thick, deco.filled([color.grey(1)])])
Ejemplo n.º 18
0

def draw_square(x, y, kante):
    c.stroke(path.rect(x, y, kante, kante),
             [style.linewidth.thick, deco.filled([color.grey(1)])])

text.set(text.LatexRunner)
unit.set(xscale=1.3)
c = canvas.canvas()

kante = 1
dist = 0.2
nrboxes = 8

c.fill(path.rect(-0.3*dist, -0.2, 5*kante+4.6*dist, kante+0.4),
       [color.grey(0.5)])
c.fill(path.rect(-0.3*dist+5*(kante+dist), -0.2, 3*kante+2.6*dist, kante+0.4),
       [color.grey(0.5)])

for n in range(nrboxes):
    x = n*(kante+dist)
    draw_square(x, 0, kante)
    c.text(x+0.5*kante, 0.5*kante, r"\texttt{%s}" % n,
           [text.halign.center, text.valign.middle])

for n in range(nrboxes+1):
    x = n*(kante+dist)
    c.stroke(path.line(x-0.5*dist, -0.5, x-0.5*dist, -0.1), [deco.earrow])
    c.text(x-0.5*dist, -0.7, r"\texttt{%s}" % n,
           [text.halign.center, text.valign.top])
Ejemplo n.º 19
0
from pyx import canvas, color, deco, deformer, graph, path, style, trafo


def ellipse(r, scaley, fillcolor):
    ce = canvas.canvas()
    ce.fill(path.circle(0, 0, r), [trafo.scale(1, scaley), fillcolor])
    return ce


c = canvas.canvas()
dx = 0.3
h = 4
w = 6.5
p = path.rect(-dx, -dx, w + 2 * dx, h + 2 * dx)
p = deformer.smoothed(0.5).deform(p)
c.fill(p, [color.grey(0.5), trafo.translate(0.05, -0.05)])

c1 = canvas.canvas([canvas.clip(p)])
c1.fill(p, [color.grey(0.9)])

r = 1
brown1 = color.rgb(148 / 255, 77 / 255, 48 / 255)
brown2 = color.rgb(193 / 255, 91 / 255, 49 / 255)
red1 = color.rgb(200 / 255, 0, 0)
red2 = color.rgb(220 / 255, 0.5, 0.5)
flame = color.rgb(248 / 255, 212 / 255, 27 / 255)
c2 = canvas.canvas()
c2.insert(ellipse(r, 0.5, brown1))
c2.fill(path.rect(-r, 0, 2 * r, 0.5 * r), [brown1])
c2.insert(ellipse(r, 0.5, brown2), [trafo.translate(0, 0.5 * r)])
c2.insert(ellipse(0.2 * r, 0.5, red1), [trafo.translate(0, 0.5 * r)])
import numpy as np
from pyx import canvas, color, path, text, unit

def draw_grid():
    c.stroke(path.rect(0, 0, 25, 2))
    for n in range(24):
        c.stroke(path.line(n+1, 0, n+1, 2))
    c.stroke(path.line(0, 1, 25, 1))

text.set(text.LatexRunner)
text.preamble(r'\usepackage[sfdefault,scaled=.85,lining]{FiraSans}\usepackage{newtxsf}')
unit.set(xscale=1.7, wscale=2.5)

c = canvas.canvas()
c.fill(path.rect(0, 1, 2, 1), [color.grey(0.7)])
c.text(0.5, 1.5, '0', [text.halign.center, text.valign.middle])
c.text(1.5, 1.5, '1', [text.halign.center, text.valign.middle])
basename = os.path.splitext(sys.argv[0])[0]
baseprimes = [0, 2, 3, 5, 7]
ncolor = len(baseprimes)-1
cancelled = set([0, 1])
for nr, baseprime in enumerate(baseprimes):
    if nr == 0:
        for n in range(2, 50):
            x = n % 25
            y = 2-(n//25)
            c.text(x+0.5, y-0.5, str(n), [text.halign.center, text.valign.middle])
    else:
        cancelled.add(baseprime)
        hvalue = 1.1*(nr-1)/(ncolor-1)
        arange = None
    drawgrid(c, 4, 3, 0, gridcolor, arange=arange)
    if hlshape is not None:
        c.stroke(path.rect(0, 3, hlshape[1], -hlshape[0]),
                 [deco.filled([color.rgb(1, 0.8, 0.4)])])
        drawgrid(c, hlshape[1], hlshape[0], 3-hlshape[0], arange=False)
    if arange is None:
        alertcolor = color.rgb(0.6, 0, 0)
        c.stroke(path.line(0, 0, 4, 3), [alertcolor, style.linewidth.Thick])
        c.stroke(path.line(0, 3, 4, 0), [alertcolor, style.linewidth.Thick])
    return c


text.set(text.LatexRunner)
text.preamble(r'\usepackage[sfdefault,scaled=.85,lining]{FiraSans}\usepackage{newtxsf}')
unit.set(xscale=1.6, wscale=1.5)

xcells = 4
ycells = 3
gridcolor = color.grey(0.5)

c = canvas.canvas()

c.insert(array34(True))
c.insert(array34(False, (1,)), [trafo.translate(5, 0)])
c.insert(array34(False, (4,)), [trafo.translate(10, 0)])
c.insert(array34(False, (3,)), [trafo.translate(5, -4.5)])
c.insert(array34(False, (3, 1)), [trafo.translate(10, -4.5)])

c.writePDFfile()
Ejemplo n.º 22
0
text.set(text.LatexRunner)
c = canvas.canvas()

codepoint = 0x00221E
bits = 24

codepointbinary = [(codepoint & 2**n) / 2**n for n in range(bits)]
codepointbinary.reverse()

size = 0.4
x0 = 0
y0 = 3
dy = 0.07
c.fill(path.rect(x0, y0, 8 * size, size),
       [color.grey(0.5), deco.stroked([color.grey(0.5)])])
c.stroke(path.rect(x0 + 8 * size, y0, 4 * size, size))
c.stroke(path.rect(x0 + 12 * size, y0, 6 * size, size))
c.stroke(path.rect(x0 + 18 * size, y0, 6 * size, size))
for n in range(len(codepointbinary)):
    c.text(x0 + (n + 0.5) * size, y0 + dy,
           r"\sffamily %i" % codepointbinary[n], [text.halign.center])

p = path.path(path.moveto(0.2 * size, size + 0.03),
              path.lineto(0.2 * size, size + 0.07),
              path.lineto(3.8 * size, size + 0.07),
              path.lineto(3.8 * size, size + 0.03))
for n in range(bits // 4):
    c.stroke(p, [trafo.translate(4 * n * size, y0)])
    c.text((4 * n + 2) * size, size + 0.14 + y0,
           r"\sffamily %X" % (codepoint >> (bits // 4 - n - 1) * 4 & 0x0f),
Ejemplo n.º 23
0
from pyx import canvas, color, deco, path, style, text, trafo, unit

ntraj = 5
radius = 0.1
dy = 0.7
width = 10
height = ntraj*dy + (ntraj//2)**2*2*radius
if ntraj % 2:
    height = height + ntraj//2*2*radius
boxwidth = 0.3
boxcolor = color.grey(0.5)
linecolor = color.rgb(0.2, 0, 0.8)
labelypos = -0.7
qi = 2
qf = 7

text.set(engine=text.LatexEngine)
text.preamble(r'''\usepackage[sfdefault,scaled=.85]{FiraSans}
                  \usepackage{newtxsf}''')
unit.set(vscale=1.2, wscale=1.3, xscale=1.8)
c = canvas.canvas()
c.fill(path.rect(0, 0, width, height), [color.rgb(0.92, 1, 0.92)])
c.fill(path.rect(0, 0, -boxwidth, height), [boxcolor])
c.stroke(path.line(0, 0, 0, height), [style.linewidth.thick])
c.text(0, labelypos, '$0$', [text.halign.center])
c.fill(path.rect(width, 0, boxwidth, height), [boxcolor])
c.stroke(path.line(width, 0, width, height), [style.linewidth.thick])
c.text(width, labelypos, '$L$', [text.halign.center])
for q, label in ((qi, r'$q_\text{i}$'),
                 (qf, r'$q_\text{f}$')):
    c.stroke(path.line(q, 0, q, height), [style.linestyle.dashed])
Ejemplo n.º 24
0

def client(clientcolor=color.rgb(0.8, 0.5, 0.5)):
    c = canvas.canvas()
    r = 0.3
    c.fill(path.circle(0, 0, r), [clientcolor])
    r = 0.5
    p = path.path(path.moveto(-r, 0), path.curveto(-r, r, r, r, r, 0),
                  path.closepath())
    c.fill(p, [clientcolor, trafo.translate(0, -1.3 * r)])
    return c


random.seed(812357)

arrowcolor = color.grey(0.5)

text.set(text.LatexRunner)
text.preamble(r'\usepackage{arev}\usepackage[T1]{fontenc}')
unit.set(xscale=1.3)

c = canvas.canvas()
pos = [(0, 1), (sin(2 * pi / 3), cos(2 * pi / 3)),
       (-sin(2 * pi / 3), cos(2 * pi / 3))]
for x, y in pos:
    c.insert(server(0.3), [trafo.translate(1.5 * x, 1.5 * y)])
    c.insert(client(), [trafo.scale(0.5).translated(3 * x, 3 * y + 0.15)])
    c.stroke(path.line(2.7 * x, 2.7 * y, 1.9 * x, 1.9 * y), [
        arrowcolor, deco.earrow.large, deco.barrow.large, style.linewidth.THick
    ])
pos.append(pos[0])
from pyx import canvas, color, deco, path, text, unit

text.set(text.LatexRunner)
text.preamble(
    r'\usepackage[sfdefault,scaled=.85,lining]{FiraSans}\usepackage{newtxsf}')
text.preamble(r'\usepackage{nicefrac}')
unit.set(xscale=1.4, wscale=1.2)

c = canvas.canvas()
r = 0.05
for n in range(1, 5):
    c.stroke(path.circle(n, 0, r))
    c.stroke(path.circle(-n, 0, r))
c.stroke(path.circle(0, 0, r), [deco.filled([color.grey(0)])])
dx = 0.1
dy = 0.3
c.stroke(path.curve(dx, dx, dy, dy, 1 - dy, dy, 1 - dx, dx), [deco.earrow])
c.text(0.5, dy + 0.1, '+1', [text.halign.center])
c.stroke(path.curve(-dx, dx, -dy, dy, -1 + dy, dy, -1 + dx, dx), [deco.earrow])
c.text(-0.5, dy + 0.1, '-1', [text.halign.center])
c.writePDFfile()
Ejemplo n.º 26
0
from pyx import canvas, color, text

text.set(text.LatexRunner)
c = canvas.canvas()
t = text.text(0, 0, r"\sffamily\bfseries ?")
tblarge = t.bbox().enlarged(0.1)
c.fill(tblarge.path(), [color.rgb(0.8, 0.5, 0)])
c.insert(t, [color.grey(1)])

c.writePDFfile()
c.writeGSfile(device="png16m", resolution=600)
Ejemplo n.º 27
0
                  path.closepath(), path.moveto(0, 0.8), path.lineto(0, 0.05),
                  path.moveto(-0.2, 0), path.arcn(-0.1, 0, 0.1, 180, 20),
                  path.arcn(0.1, 0, 0.1, 160, 0))
    cwrite.stroke(
        p, [color,
            trafo.scale(size).rotated(-30).translated(0, -0.4 * size)])
    return cwrite


text.set(text.LatexRunner)
text.preamble(r'\usepackage{arev}\usepackage[T1]{fontenc}')
c = canvas.canvas()

wd = 6.9
ht = 3.5
gitlabfgcolor = color.grey(0.4)
gitlabbgcolor = color.grey(0.97)
maintainercolor = color.hsb(0.7, 1, 0.5)
usercolor = color.hsb(0.05, 1, 0.5)
c.stroke(path.rect(0, 0, wd, ht), [
    deformer.smoothed(0.1), gitlabfgcolor, style.linewidth.Thick,
    deco.filled([gitlabbgcolor])
])

clabel = canvas.canvas()
labeltext = text.text(0, 0, r'\textsf{\bfseries Gitlab}', [color.grey(1)])
extrawd = 0.15
labelbox = labeltext.bbox().enlarged(extrawd)
clabel.fill(labelbox.path(), [gitlabfgcolor, deformer.smoothed(0.1)])
clabel.insert(labeltext)
c.insert(clabel, [trafo.translate(extrawd, ht + extrawd)])
Ejemplo n.º 28
0
    return c

def client(clientcolor=color.rgb(0.8, 0.5, 0.5)):
    c = canvas.canvas()
    r = 0.3
    c.fill(path.circle(0, 0, r), [clientcolor])
    r = 0.5
    p = path.path(path.moveto(-r, 0),
                  path.curveto(-r, r, r, r, r, 0),
                  path.closepath())
    c.fill(p, [clientcolor, trafo.translate(0, -1.3*r)])
    return c

random.seed(812357)

arrowcolor = color.grey(0.5)

text.set(text.LatexRunner)                                                                           
text.preamble(r'\usepackage{arev}\usepackage[T1]{fontenc}')
unit.set(xscale=1.3)

c = canvas.canvas()
pos = [(0, 1), (sin(2*pi/3), cos(2*pi/3)), (-sin(2*pi/3), cos(2*pi/3))]
for x, y in pos:
    c.insert(server(0.3), [trafo.translate(1.5*x, 1.5*y)])
    c.insert(client(), [trafo.scale(0.5).translated(3*x, 3*y+0.15)])
    c.stroke(path.line(2.7*x, 2.7*y, 1.9*x, 1.9*y),
               [arrowcolor, deco.earrow.large, deco.barrow.large, style.linewidth.THick])
pos.append(pos[0])
fak = 0.3
for (x1, y1), (x2,y2) in zip(pos[:-1], pos[1:]):
Ejemplo n.º 29
0
import numpy as np
from pyx import canvas, color, path, text, unit

def draw_grid():
    c.stroke(path.rect(0, 0, 25, 2))
    for n in range(24):
        c.stroke(path.line(n+1, 0, n+1, 2))
    c.stroke(path.line(0, 1, 25, 1))

text.set(text.LatexRunner)
text.preamble(r'\usepackage{arev}\usepackage[T1]{fontenc}')
unit.set(xscale=1.2, wscale=2.5)

c = canvas.canvas()
c.fill(path.rect(0, 1, 2, 1), [color.grey(0.7)])
c.text(0.5, 1.5, '0', [text.halign.center, text.valign.middle])
c.text(1.5, 1.5, '1', [text.halign.center, text.valign.middle])
basename = os.path.splitext(sys.argv[0])[0]
baseprimes = [0, 2, 3, 5, 7]
ncolor = len(baseprimes)-1
cancelled = set([0, 1])
for nr, baseprime in enumerate(baseprimes):
    if nr == 0:
        for n in range(2, 50):
            x = n % 25
            y = 2-(n//25)
            c.text(x+0.5, y-0.5, str(n), [text.halign.center, text.valign.middle])
    else:
        cancelled.add(baseprime)
        hvalue = 1.1*(nr-1)/(ncolor-1)
Ejemplo n.º 30
0
text.preamble(r'\usepackage{arev}\usepackage[T1]{fontenc}')

c = canvas.canvas()
ht = 5
htlabel = 1
wd = 3.5
vdist = 0.05
hdist = 1
size = 1.2

for nr, (label, boxcolor, symbolcolor, status) in enumerate(
    (('working directory', color.hsb(0.87, 1, 0.6), color.rgb(0.6, 0,
                                                              0), 'modified'),
     ('staging area', color.hsb(0.2, 1, 0.6), color.rgb(0, 0.5, 0), 'staged'),
     ('repository (.git)', color.hsb(0.53, 1,
                                     0.6), color.grey(0.3), 'committed'))):
    xmid = nr * (wd + hdist) + 0.5 * wd
    c.stroke(path.rect(nr * (wd + hdist), 0, wd, ht),
             [deformer.smoothed(0.3), boxcolor, style.linewidth.Thick])
    c.fill(path.rect(nr * (wd + hdist), ht + vdist, wd, htlabel),
           [deformer.smoothed(0.3), boxcolor])
    c.text(xmid, ht + vdist + 0.5 * htlabel, label,
           [text.halign.center, text.valign.middle,
            color.grey(1)])
    c.insert(filesymbol(size, symbolcolor), [trafo.translate(xmid, 0.5 * ht)])
    c.text(xmid, 0.2 * ht, status, [text.halign.center, symbolcolor])
for nr, operation in enumerate(('git add', 'git commit')):
    xmid = nr * (wd + hdist) + 0.5 * wd
    c.stroke(
        path.line(xmid + 0.5 * size + 0.1, 0.5 * ht,
                  xmid + wd + hdist - 0.5 * size - 0.1, 0.5 * ht),
Ejemplo n.º 31
0
boxwidth = 3
height = 4
qi = 0.2 * boxwidth
qf = 0.7 * boxwidth
linecolor = color.rgb(0.2, 0, 0.8)

text.set(engine=text.LatexEngine)
text.preamble(r'''\usepackage[sfdefault,scaled=.85]{FiraSans}
                  \usepackage{newtxsf}''')
unit.set(vscale=1.2, wscale=1.3, xscale=1.3)
c = canvas.canvas()
c.fill(path.rect(0, 0, boxwidth, height), [color.rgb(0.92, 1, 0.92)])
for n in range(-1, 4):
    c.stroke(path.line(n * boxwidth, 0, n * boxwidth, height),
             [style.linewidth.THick, color.grey(0.4)])
poslinestyle = (style.linestyle.dashed, style.linewidth.thick)
c.stroke(path.line(qi, 0, qi, height), [*poslinestyle, color.rgb(0.2, 0.6, 0)])
for n in range(-1, 2):
    q = qf + 2 * n * boxwidth
    c.stroke(path.line(q, 0, q, height), [*poslinestyle, color.rgb(0.6, 0, 0)])
for n in range(-1, 1):
    q = -qf + (2 * n + 2) * boxwidth
    c.stroke(path.line(q, 0, q, height), [*poslinestyle, color.rgb(0.6, 0, 0)])
for delta in (2 * (boxwidth - qf), -2 * qf):
    c.stroke(
        path.curve(qf, -0.1, qf + 0.3 * delta, -0.5, qf + 0.7 * delta, -0.5,
                   qf + delta, -0.1), [deco.earrow])
for delta in (-4 * boxwidth + 2 * qf, 2 * qf):
    c.stroke(
        path.curve(2 * boxwidth - qf, height + 0.1,
                  \definecolor{ex1}{rgb}{0, 0, 0.7}
                  \definecolor{ex2}{rgb}{0, 0.6, 0}
                  \definecolor{ex3}{rgb}{0.7, 0, 0}''')
unit.set(xscale=1.2)

c = canvas.canvas()

ex1color = color.rgb(0, 0, 0.7)
linewidth = 0.1*boxsize
for n in (0, 2, 5):
    c.fill(path.rect(n*boxsize+linewidth, linewidth,
                     boxsize-2*linewidth, 3*boxsize-2*linewidth),
           [ex1color])
    c.fill(path.rect(n*boxsize+2*linewidth, 2*linewidth,
                     boxsize-4*linewidth, 3*boxsize-4*linewidth),
           [color.grey(1)])

ex2color = color.rgb(0, 0.6, 0)
linewidth = 0.1
for n in range(5):
    markbox((n+1)*boxsize, (ncols-n-1)*boxsize, ex2color)

ex3color = color.rgb(0.7, 0, 0)
linewidth = 0.1
for n in (0, 2, 5):
    markbox(2*boxsize, (ncols-n-1)*boxsize, ex3color)

for nx in range(ncols+1):
    p = path.path(path.moveto(nx*boxsize, 0),
                  path.lineto(nx*boxsize, ncols*boxsize),
                  path.rlineto(reducedboxsize*cos(angle), reducedboxsize*sin(angle)))
text.preamble(r'\usepackage[sfdefault,scaled=.85,lining]{FiraSans}\usepackage{newtxsf}')
unit.set(xscale=1.6, wscale=1.5)

frontplane = canvas.canvas()
backplane = canvas.canvas()
xcells = 4
ycells = 3
xshift = 0.8
yshift = 1.2
dist = 0.2
myred = color.rgb(0.8, 0, 0)
mygreen = color.rgb(0, 0.6, 0)
myblue = color.rgb(0, 0, 0.8)
for c, start in ((frontplane, 0), (backplane, xcells*ycells)):
    c.stroke(path.rect(0, 0, 4, 3),
             [deco.filled([color.grey(1), color.transparency(0.2)])])
    for x in range(1, xcells):
        c.stroke(path.line(x, 0, x, ycells))
    for y in range(1, ycells):
        c.stroke(path.line(0, y, xcells, y))
    for entry in range(xcells*ycells):
        x = entry % 4
        y = ycells - entry // 4
        c.text(x+0.5, y-0.5, str(start+entry),
               [text.halign.center, text.valign.middle])
c = canvas.canvas()
c.insert(backplane, [trafo.translate(xshift, yshift)])
for x, y in product((0, xcells), (0, ycells)):
    c.stroke(path.line(x, y, x+xshift, y+yshift))
c.insert(frontplane)
dx = -dist*yshift/sqrt(xshift**2+yshift**2)
Ejemplo n.º 34
0
for nplane, (edgecolor, facecolor) in enumerate(zip(edgecolors, facecolors)):
    zoff = 1.04*(2-nplane)
    frontplane(xoff, yoff, zoff+1, nxmax, nymax, facecolor, edgecolor, trans)
    for nx in range(nxmax, -1, -1):
        for ny in range(nymax+1):
            corner(xoff+nx, yoff+ny, zoff, facecolor, edgecolor, trans,
                   nx != 0, ny != nymax)
    frontplane(xoff, yoff, zoff, nxmax, nymax, facecolor, edgecolor, trans)
x0, _ = projector(xoff+0.5*nxmax, 0, yoff)
y0 = -2.4
c.text(x0, y0, r"\sffamily Farbbild (RGB-Format)", [text.halign.center, text.valign.top])
c.text(x0, y0-0.7, r"\sffamily N$\times$M$\times$3-Array", [text.halign.center, text.valign.top])

xoff = -4
yoff = 0
edgecolor = color.grey(0)
w = 0.3
facecolor = color.grey(0.7)
nplane = 2
zoff = 1.04*(2-nplane)-2
frontplane(xoff, yoff, zoff+1, nxmax, nymax, facecolor, edgecolor, trans)
for nx in range(nxmax, -1, -1):
    for ny in range(nymax+1):
        corner(xoff+nx, yoff+ny, zoff, facecolor, edgecolor, trans,
               nx != 0, ny != nymax)
frontplane(xoff, yoff, zoff, nxmax, nymax, facecolor, edgecolor, trans)
x0, _ = projector(xoff+0.5*nxmax, zoff, yoff)
y0 = -2.4
c.text(x0, y0, r"\sffamily Schwarz-Weiß-Bild", [text.halign.center, text.valign.top])
c.text(x0, y0-0.7, r"\sffamily N$\times$M-Array", [text.halign.center, text.valign.top])
c.writePDFfile()
Ejemplo n.º 35
0
from pyx import canvas, color, deco, path, style, text, trafo, unit

width = 8
height = 4
linecolor1 = color.rgb(0.2, 0, 0.8)
linecolor2 = color.rgb(0.8, 0.3, 0)
qi = 1.2
qf = 3.2
t = 3.5

text.set(engine=text.LatexEngine)
text.preamble(r'''\usepackage[sfdefault,scaled=.85]{FiraSans}
                  \usepackage{newtxsf}''')
unit.set(vscale=1.2, wscale=1.3, xscale=1.3)
c = canvas.canvas()
c.fill(path.rect(0, 0, -0.3, height-0.3), [color.grey(0.5)])
c.stroke(path.line(-0.5*width, 0, 0.5*width, 0), [deco.earrow])
c.text(0.5*width+0.1, 0, '$q$', [text.valign.middle])
c.stroke(path.line(0, 0, 0, height), [deco.earrow])
c.text(0.2, height, '$t$', [text.valign.top])
c.stroke(path.path(path.moveto(qi, 0),
                   path.curveto(qi, 0.5, qi+0.2, 1.3, qi+0.8, 1.6),
                   path.curveto(qi+1.4, 1.9, qf+0.7, 3, qf, t)),
         [style.linewidth.thick, linecolor1])
c.stroke(path.path(path.moveto(qi, 0),
                   path.curveto(0.5*qi, 0.5, -2.5, 1.3, 0, 1.6)),
         [style.linewidth.thick, linecolor2])
p = path.path(path.moveto(0, 1.6),
              path.curveto(2.5, 1.9, 3, 3, qf, t))
c.stroke(p, [style.linewidth.thick, linecolor2])
c.stroke(p, [style.linewidth.thick, style.linestyle.dashed,
Ejemplo n.º 36
0
text.set(text.LatexRunner)
c = canvas.canvas()

codepoint = 0x00E9
bits = 16

codepointbinary = [(codepoint & 2**n)/2**n for n in range(bits)]
codepointbinary.reverse()

size = 0.4
x0 = 0
y0 = 3
dy = 0.07
c.fill(path.rect(x0, y0, 5*size, size),
       [color.grey(0.5), deco.stroked([color.grey(0.5)])])
c.stroke(path.rect(x0+5*size, y0, 5*size, size))
c.stroke(path.rect(x0+10*size, y0, 6*size, size))
for n in range(len(codepointbinary)):
    c.text(x0+(n+0.5)*size, y0+dy, r"\sffamily %i" % codepointbinary[n],
           [text.halign.center])

p = path.path(path.moveto(0.2*size, size+0.03),
              path.lineto(0.2*size, size+0.07),
              path.lineto(3.8*size, size+0.07),
              path.lineto(3.8*size, size+0.03))
for n in range(bits//4):
    c.stroke(p, [trafo.translate(4*n*size, y0)])
    c.text((4*n+2)*size, size+0.14+y0, r"\sffamily %X" %
           (codepoint >> (bits//4-n-1)*4 & 0x0f),
           [text.halign.center])
Ejemplo n.º 37
0
def draw_square(x, y, kante):
    c.stroke(path.rect(x, y, kante, kante),
             [style.linewidth.thick,
              deco.filled([color.grey(1)])])


text.set(text.LatexRunner)
unit.set(xscale=1.3)
c = canvas.canvas()

kante = 1
dist = 0.2
nrboxes = 8

c.fill(path.rect(-0.3 * dist, -0.2, 5 * kante + 4.6 * dist, kante + 0.4),
       [color.grey(0.5)])
c.fill(
    path.rect(-0.3 * dist + 5 * (kante + dist), -0.2, 3 * kante + 2.6 * dist,
              kante + 0.4), [color.grey(0.5)])

for n in range(nrboxes):
    x = n * (kante + dist)
    draw_square(x, 0, kante)
    c.text(x + 0.5 * kante, 0.5 * kante, r"\texttt{%s}" % n,
           [text.halign.center, text.valign.middle])

for n in range(nrboxes + 1):
    x = n * (kante + dist)
    c.stroke(path.line(x - 0.5 * dist, -0.5, x - 0.5 * dist, -0.1),
             [deco.earrow])
    c.text(x - 0.5 * dist, -0.7, r"\texttt{%s}" % n,
from pyx import canvas, color, deco, path, text, unit

text.set(text.LatexRunner)
text.preamble(r'\usepackage[sfdefault,scaled=.85,lining]{FiraSans}\usepackage{newtxsf}')
text.preamble(r'\usepackage{nicefrac}')
unit.set(xscale=1.4, wscale=1.2)

c = canvas.canvas()
r = 0.05
for n in range(1, 5):
    c.stroke(path.circle(n, 0, r))
    c.stroke(path.circle(-n, 0, r))
c.stroke(path.circle(0, 0, r), [deco.filled([color.grey(0)])])
dx = 0.1
dy = 0.3
c.stroke(path.curve(dx, dx, dy, dy, 1-dy, dy, 1-dx, dx), [deco.earrow])
c.text(0.5, dy+0.1, '+1', [text.halign.center])
c.stroke(path.curve(-dx, dx, -dy, dy, -1+dy, dy, -1+dx, dx), [deco.earrow])
c.text(-0.5, dy+0.1, '-1', [text.halign.center])
c.writePDFfile()
Ejemplo n.º 39
0
        arange = None
    drawgrid(c, 4, 3, 0, gridcolor, arange=arange)
    if hlshape is not None:
        c.stroke(path.rect(0, 3, hlshape[1], -hlshape[0]),
                 [deco.filled([color.rgb(1, 0.8, 0.4)])])
        drawgrid(c, hlshape[1], hlshape[0], 3 - hlshape[0], arange=False)
    if arange is None:
        alertcolor = color.rgb(0.6, 0, 0)
        c.stroke(path.line(0, 0, 4, 3), [alertcolor, style.linewidth.Thick])
        c.stroke(path.line(0, 3, 4, 0), [alertcolor, style.linewidth.Thick])
    return c


text.set(text.LatexRunner)
text.preamble(r'\usepackage{arev}\usepackage[T1]{fontenc}')
unit.set(xscale=1.2, wscale=1.5)

xcells = 4
ycells = 3
gridcolor = color.grey(0.5)

c = canvas.canvas()

c.insert(array34(True))
c.insert(array34(False, (1, )), [trafo.translate(5, 0)])
c.insert(array34(False, (4, )), [trafo.translate(10, 0)])
c.insert(array34(False, (3, )), [trafo.translate(5, -4.5)])
c.insert(array34(False, (3, 1)), [trafo.translate(10, -4.5)])

c.writePDFfile()
Ejemplo n.º 40
0
def draw_square(x, y, kante):
    c.fill(path.rect(x, y, kante, kante), [color.grey(1)])
    c.stroke(path.line(x, y, x + kante, y + kante),
             [style.linewidth.thick, color.grey(0.5)])
    c.stroke(path.rect(x, y, kante, kante), [style.linewidth.thick])
Ejemplo n.º 41
0
from pyx import color, deco, graph, style, unit

unit.set(xscale=1.3)

g = graph.graphxy(width=8,
                  x=graph.axis.linear(title="$x$"),
                  y=graph.axis.linear(title="$y$"))
g.plot(graph.data.file("pyx1.dat", x=1, y=2),
       [graph.style.line([style.linestyle.dashed, color.rgb(0, 0, 1)]),
        graph.style.symbol(graph.style.symbol.circle, size=0.1,
                           symbolattrs=[deco.filled([color.rgb.red]),
                                        deco.stroked([color.grey(0)])])])
g.writePDFfile()
g.writeGSfile(device="png16m", resolution=800)