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
Esempio n. 2
0
from pyx import canvas, path, deco, trafo, style, text, color, unit, epsfile, deformer



rgb = color.rgb
rgbfromhexstring = color.rgbfromhexstring

red, green, blue, yellow = (rgb.red,
    rgbfromhexstring("#008000"),
    rgb.blue, rgb(0.75, 0.75, 0))

blue = rgb(0., 0., 0.8)
lred = rgb(1., 0.4, 0.4)


text.set(mode="latex") 
#text.set(docopt="10pt")
text.preamble(r'\usepackage{amsfonts}')
text.preamble(r"\def\I{\mathbb{I}}")


c = canvas.canvas()
# [trafo.scale(10.)])

# Dimensions of A0 in cm
SCALE = 4.
#w = 118.9 / SCALE
#h = 84.1 / SCALE

# portrait
w = 84.1 / SCALE
Esempio n. 3
0
#!/usr/bin/env python

import sys
from math import *
from random import *
import numpy

from pyx import canvas, path, deco, trafo, style, text, color, deformer

text.set(mode="latex") 
text.set(docopt="12pt")
text.preamble(r"\usepackage{amsmath,amsfonts,amssymb}")

rgb = color.rgb
rgbfromhexstring = color.rgbfromhexstring

red, green, blue, yellow = (
    rgbfromhexstring("#d00000"),
    rgbfromhexstring("#006000"),
    rgb.blue, rgb(0.75, 0.75, 0)) 

black = rgb(0., 0., 0.) 
blue = rgb(0., 0., 0.8)
lred = rgb(1., 0.4, 0.4)
white = rgb(1., 1., 1.) 

shade = rgb(0.75, 0.55, 0)
grey = rgb(0.75, 0.75, 0.75)

light_shade = rgb(0.85, 0.65, 0.1)
light_shade = rgb(0.9, 0.75, 0.4)
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()
Esempio n. 5
0
 def setUp(self):
     text.set(mode="latex")
     text.preamble(r"\usepackage{graphicx}")
Esempio n. 6
0
'''
Created on Feb 17, 2014

@author: Vishal
'''
import os
import traceback

try:
    from pyx import graph, text, style, color
    text.set(texdebug="hello", errordebug=2)    # debug pyx
except:
    traceback.print_exc()
    print '-------------------------------------------------------------'
    print 'Graphing module PyX is not available.'
    print 'Please install (pip install PyX and and then run this program'
    print '-------------------------------------------------------------'


def plot2d(data, mytitle, result_dir=None, xaxistitle="X", yaxistitle="Y", mycolor=(0,0,0), minpoint=None, maxpoint=None):
    '''
    data: list of tuples of (x,y)
    mytitle: determines the name of the of PDF file.
    
    Graphs min/max is automatically chosen as to cover the range with 0,1 being covered.
    To override, provide the defaults minpoint (x,y) and maxpoint(x,y)
    '''
    try:
        fnameprefix = '-'.join(mytitle.split()) + '-2d'
        if result_dir: fnameprefix = os.path.join(result_dir, fnameprefix)
        datafile    = fnameprefix + '.dat'
Esempio n. 7
0
from pyx import canvas, color, deco, path, text, trafo, unit

text.set(text.LatexRunner)
color0 = color.rgb(0.8, 0, 0)
color1 = color.rgb(0, 0, 0.8)
text.preamble(r'\usepackage{arev}\usepackage[T1]{fontenc}')
text.preamble(r'\usepackage{color}')
text.preamble(r'\definecolor{axis0}{rgb}{%s, %s, %s}' %
              (color0.r, color0.g, color0.b))
text.preamble(r'\definecolor{axis1}{rgb}{%s, %s, %s}' %
              (color1.r, color1.g, color1.b))
unit.set(xscale=1.2, wscale=1.5)

dx = 2
dy = 0.8
c = canvas.canvas()
for nx in range(3):
    for ny in range(3):
        c.text(nx * dx, -ny * dy,
               r'a[\textcolor{axis0}{%s}, \textcolor{axis1}{%s}]' % (ny, nx),
               [text.halign.center])
box = c.bbox()
pd = 0.1
xoff = box.left() - pd
pdx = 0.2
pdy = 0.5
c.stroke(
    path.curve(xoff,
               box.top() + pd, xoff - pdx,
               box.top() - pdy, xoff - pdx,
               box.bottom() + pdy, xoff,
Esempio n. 8
0
#!/usr/bin/env python

import sys
import os

import numpy
from math import log
from pyx import canvas, text, path, graph, color, trafo, unit, attr, deco, style

unit.set(defaultunit="cm")
text.set(mode="latex")
text.preamble(r"\usepackage{times}")
text.preamble(r"\usepackage{sansmath}")
text.preamble(r"\sansmath")
text.preamble(r"\renewcommand*\familydefault{\sfdefault}")
painter = graph.axis.painter.regular(labeldist=0.1,
                                     labelattrs=[text.size(-3)],
                                     titleattrs=[text.size(-2)])


def main():
    out_fname = sys.argv[1]
    basedir = '/'.join(
        os.path.dirname(os.path.realpath(__file__)).split('/')[:-2])
    bin_file = '%s/Analysis/hifive_mm9_ESC_prob_correlations.txt' % basedir
    pois_file = '%s/Analysis/hifive_mm9_ESC_probpois_correlations.txt' % basedir
    bin_data = load_data(bin_file)
    pois_data = load_data(pois_file)
    width = 16.8
    spacer = 0.4
    range_width = (width - spacer) / 5.0
Esempio n. 9
0
 def setUp(self):
     text.set(mode="latex")
     text.preamble(r"\usepackage{graphicx}")
Esempio n. 10
0
from collections import deque
from features import *
from numpy import arctan2, sqrt
from numpy.linalg import norm
from numpy import array, roll, sqrt, argmin
from math import ceil, floor, nan, isnan
from pyx import path, canvas as pyxcanvas, color as pyxcolor, text, style
text.set(text.UnicodeEngine)

eps = 0.01  # numerical tolerance


class Schematic:
    """Schematic lays out the stack of devices.

    wrap:
        type: int
        default: 10000
        description: number of devices to display vertically before beginning on a new column.
    ysep:
        type: float
        default: 100.
        description: y-separation of devices in schematic
    xsep:
        type: float
        default: 50.
        description: x-separation of devices in schematic
    devices_xy:
        type: deque
        default: empty deque
        description: deque of 2-tuples, index 0 is Device object, index 1 is 2-tuple of x- and y-shift
 def initialize_pyx(self):
     text.set(text.LatexRunner)
     text.preamble(r'\usepackage[sfdefault,scaled=.85,lining]{FiraSans}\usepackage{newtxsf}')
     unit.set(xscale=2.5, wscale=7)