当前位置: 首页>>代码示例>>Python>>正文


Python canvas.canvas函数代码示例

本文整理汇总了Python中pyx.canvas.canvas函数的典型用法代码示例。如果您正苦于以下问题:Python canvas函数的具体用法?Python canvas怎么用?Python canvas使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了canvas函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find

 def find(self, file=''):
     """
     This is the meat of the algorithm. It takes the frame and runs the steps outlined
     in the report. So if you've read the report this should be pretty self explanatory.
     """
     dimension = 0
     while True:
         print '--> generating linear system'
         linear_system = self.generate_linear_system()
         print '     size is %s, %s' % (len(linear_system), len(linear_system[0]))
         print '--> trying to find a solution'
         vector_solution = self.solve(linear_system)
         if vector_solution is None:
             print '--> solution not found'
             print '--> doubling along dimension %s' % dimension
             self.frame.double(dimension)
             dimension = (dimension + 1) % self.dimensions
         else:
             break
     solution = self.normalize_solution(vector_solution)
     self.set_edge_weights(solution)
     if file:
         c = canvas.canvas()
         self.draw_edges(c)
         c.writePDFfile(file)
开发者ID:erebuseternal,项目名称:kirky,代码行数:25,代码来源:__init__.py

示例2: draw

    def draw(self, r=5):
        c = canvas.canvas()

        x_centre = r + 1
        y_centre = r + 1

        angle_diff = 2*math.pi/self.n

        def get_pos(index):
            x_pos = x_centre + math.sin(index*angle_diff)*r
            y_pos = y_centre + math.cos(index*angle_diff)*r
            return x_pos, y_pos

        # nodes
        for i in range(self.n):
            x, y = get_pos(i)
            c.stroke(path.circle(x, y, 1))
            c.text(x, y, i)

        # edges
        for i in range(self.n):
            for j in range(self.n):
                if math.isnan(self.adj_mat[i, j]):
                    continue
                x1, y1 = get_pos(i)
                x2, y2 = get_pos(j)
                x_offset = (x2 - x1)/math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
                y_offset = (y2 - y1)/math.sqrt((x1 - x2)**2 + (y1 - y2)**2)
                arc = path.line(x1 + x_offset, y1 + y_offset, x2 - x_offset, y2 - y_offset)
                c.stroke(arc, [deco.earrow()])
                c.text((x1 + x2)/2 + x_offset, (y1 + y2)/2 + y_offset, self.adj_mat[i, j])  # moved towards the end pt

        c.writePDFfile("graph")
开发者ID:silverfield,项目名称:pythonsessions,代码行数:33,代码来源:graph.py

示例3: make_picture_for_two_vertices

def make_picture_for_two_vertices():
    c = canvas.canvas()
    c.stroke(path.rect(0, 0, 12, 1))
    c.stroke(path.rect(1, 0, 1, 1), [style.linewidth.THICK])
    c.stroke(path.rect(5, 0, 1, 1), [style.linewidth.THICK])
    c.stroke(path.rect(7, 0, 1, 1), [style.linewidth.THICK])
    c.stroke(path.rect(10, 0, 1, 1), [style.linewidth.THICK])
    c.stroke(path.line(-0.5, 0.5, -0.5, 6), [deco.earrow(size=0.2)])
    c.stroke(path.line(1.5, 0.5, 1.5, 5), [deco.earrow(size=0.2)])
    c.stroke(path.line(5.5, 0.5, 5.5, 4), [deco.earrow(size=0.2)])
    c.stroke(path.line(7.5, 0.5, 7.5, 3), [deco.earrow(size=0.2)])
    c.stroke(path.line(10.5, 0.5, 10.5, 2), [deco.earrow(size=0.2)])
    c.stroke(path.line(12.5, 0.5, 12.5, 1), [deco.earrow(size=0.2)])
    c.stroke(path.line(5.5, 4, 8, 4), [style.linewidth.THIN])
    c.stroke(path.line(7, 3, 8, 3), [style.linewidth.THIN])
    c.text(7.5, 3.5, r"$\delta_i = l_i - l_{i + 1}$", [text.halign.boxcenter, text.valign.middle])
    c.stroke(path.line(6, 0, 6, -1), [style.linewidth.THIN])
    c.stroke(path.line(7, 0, 7, -1), [style.linewidth.THIN])
    c.text(6.5, -0.4, r"$d_i$", [text.halign.boxcenter, text.valign.middle])
    c.text(-0.5, 3, r"$l_0 = 1.0$", [text.halign.boxleft])
    c.text(5.5, 2.5, r"$l_i$", [text.halign.boxright])
    c.text(7.5, 2, r"$l_{i+1}$", [text.halign.boxleft])
    c.text(12.5, 1.1, r"$l_{E+1} = 0.0$", [text.halign.boxcenter])

    c.writePDFfile("test_picture.pdf")
开发者ID:AntipovDen,项目名称:Master,代码行数:25,代码来源:Kmu_plots.py

示例4: main

def main():
    out_fname = sys.argv[1]
    basedir = '/'.join(os.path.dirname(os.path.realpath(__file__)).split('/')[:-2])
    mm9_methods = {
        '0 pseudo-counts':'%s/Analysis/hifive_mm9_ESC_bin_correlations.txt' % basedir, 
        '1 pseudo-count':'%s/Analysis/hifive_mm9_ESC_binPC1_correlations.txt' % basedir, 
        '3 pseudo-counts':'%s/Analysis/hifive_mm9_ESC_binPC3_correlations.txt' % basedir, 
        '6 pseudo-counts':'%s/Analysis/hifive_mm9_ESC_binPC6_correlations.txt' % basedir, 
        'HiCPipe':'%s/Analysis/hicpipe_mm9_ESC_correlations.txt' % basedir, 
    }
    mm9_data = load_data(mm9_methods)
    width = 16.8
    spacer = 0.4
    overall_width = (width - spacer * 2) / 2.6
    c = canvas.canvas()
    prob_ranges_img, prob_ranges_height = plot_dataset_ranges(mm9_data, width)
    prob_ranges_img.text(0, prob_ranges_height, 'a',
                        [text.halign.left, text.valign.top, text.size(-1)])
    c.insert(prob_ranges_img)
    overall_height = prob_ranges_height * 0.6
    hifive_overall_img = plot_overall(mm9_data, overall_width, overall_height, 'cis')
    hifive_overall_img.text(0, overall_height + 0.1, 'b',
                        [text.halign.left, text.valign.top, text.size(-1)])
    c.insert(hifive_overall_img, [trafo.translate(0, -overall_height - spacer)])
    hifive_overall_img = plot_overall(mm9_data, overall_width, overall_height, 'trans')
    hifive_overall_img.text(0, overall_height + 0.1, 'c',
                        [text.halign.left, text.valign.top, text.size(-1)])
    c.insert(hifive_overall_img,
             [trafo.translate(width - overall_width, -overall_height - spacer)])
    c.insert(plot_key(overall_width * 0.6 + 0.4, overall_height, mm9_data),
             [trafo.translate(overall_width + spacer + 0.6, -overall_height - spacer)])
    c.writePDFfile(out_fname)
开发者ID:bxlab,项目名称:HiFive_Paper,代码行数:32,代码来源:pseudocount_comparison.py

示例5: main

def main():
    width = 16.8
    out_fname = sys.argv[1]
    basedir = "%s/Analysis/Timing" % '/'.join(os.path.dirname(os.path.realpath(__file__)).split('/')[:-2])
    data_fnames = {
        "HiFive-Probability":{'0':"%s/hifive_data" % basedir, '1':"%s/hifive_project" % basedir,
                '3':'%s/hifive_prob' % basedir, '4':"%s/hifive_prob_heatmap" % basedir},
        "HiFive-Binning":{'0':"%s/hifive_data" % basedir, '1':"%s/hifive_project_nodist" % basedir,
               '3':'%s/hifive_bin' % basedir, '4':"%s/hifive_bin_heatmap" % basedir},
        "HiFive-Express":{'0':"%s/hifive_data" % basedir, '1':"%s/hifive_project" % basedir,
               '3':'%s/hifive_exp' % basedir, '4':"%s/hifive_exp_heatmap" % basedir},
        "HiFive-ExpressKR":{'0':"%s/hifive_data" % basedir, '1':"%s/hifive_project_nodist" % basedir,
                 '3':'%s/hifive_expKR' % basedir, '4':"%s/hifive_expKR_heatmap" % basedir},
        "HiFive-ExpressKR w/distance":{'0':"%s/hifive_data" % basedir, '1':"%s/hifive_project" % basedir,
                     '3':'%s/hifive_expKRdist' % basedir, '4':"%s/hifive_expKRdist_heatmap" % basedir},
        "HiCPipe":{'0':"%s/bam2raw" % basedir, '1':"%s/hicpipe_data" % basedir,
                   '2':'%s/hicpipe_binning' % basedir, '3':'%s/hicpipe_norm' % basedir,
                   '4':'%s/hicpipe_heatmap' % basedir},
        "HiCLib":{'0':"%s/hiclib_mapping" % basedir, '1':'%s/hiclib_data' % basedir,
                  '3':"%s/hiclib_norm" % basedir, '4':'%s/hiclib_heatmap' % basedir},
        "HiCNorm":{'0':"%s/bam2raw" % basedir, '1':"%s/hicpipe_data" % basedir,
                   "2":"%s/hicnorm_data" % basedir, '3':'%s/hicnorm_norm' % basedir},
    }
    data = load_data(data_fnames)
    c = canvas.canvas()
    c.insert(plot_bargraph(data, width, 4.0), [trafo.translate(4.0, 0)])
    c.insert(plot_key(width * 0.3, 1.5), [trafo.translate(width * 0.75 - 1.0, 0.2)])
    c.writePDFfile(out_fname)
开发者ID:bxlab,项目名称:HiFive_Paper,代码行数:28,代码来源:time_comparison.py

示例6: processPS

    def processPS(self, file, writer, context, registry, bbox):
        if writer.mesh_as_bitmap:
            from pyx import bitmap, canvas
            from PIL import Image
            c = canvas.canvas()
            c.insert(self)
            i = Image.open(c.pipeGS("pngalpha", resolution=writer.mesh_as_bitmap_resolution))
            i.load()
            b = bitmap.bitmap_pt(self.bbox().llx_pt, self.bbox().lly_pt, i)
            # we slightly shift the bitmap to re-center it, as the bitmap might contain some additional border
            # unfortunately we need to construct another bitmap instance for that ...
            b = bitmap.bitmap_pt(self.bbox().llx_pt + 0.5*(self.bbox().width_pt()-b.bbox().width_pt()),
                                 self.bbox().lly_pt + 0.5*(self.bbox().height_pt()-b.bbox().height_pt()), i)
            b.processPS(file, writer, context, registry, bbox)
        else:
            thisbbox = self.bbox()
            bbox += thisbbox
            file.write("""<< /ShadingType 4
/ColorSpace %s
/BitsPerCoordinate 24
/BitsPerComponent 8
/BitsPerFlag 8
/Decode [%f %f %f %f %s]
/DataSource currentfile /ASCIIHexDecode filter /FlateDecode filter
>> shfill\n""" % (self.elements[0].nodes[0].value.colorspacestring(),
                  thisbbox.llx_pt, thisbbox.urx_pt, thisbbox.lly_pt, thisbbox.ury_pt,
                  " ".join(["0 1" for value in self.elements[0].nodes[0].value.to8bitbytes()])))
            file.write_bytes(binascii.b2a_hex(zlib.compress(self.data(thisbbox))))
            file.write(">\n")
开发者ID:mjg,项目名称:PyX-svn,代码行数:29,代码来源:mesh.py

示例7: try_size

 def try_size(self, frame_shape, file=''):
     # first we setup the block anew
     self.frame = Frame(self.dimensions, self.num_vectors, self.steps)
     first_frame_shape = self.get_first_frame_shape()
     self.frame.seed_frame(first_frame_shape)
     cross_vectors = self.get_cross_vectors()
     for vector in cross_vectors:
         self.frame.populate(vector)
     # now we try to grow our block to the right size
     if not self.frame.grow_to_size(frame_shape):
         return None
     print '--> generating linear system'
     linear_system = self.generate_linear_system()
     print '     size is %s, %s' % (len(linear_system), len(linear_system[0]))
     print '--> trying to find a solution'
     vector_solution = self.solve(linear_system)
     if vector_solution is None:
         print '--> solution not found'
         return None
     else:
         print '--> solution found'
     solution = self.normalize_solution(vector_solution)
     self.set_edge_weights(solution)
     if file:
         c = canvas.canvas()
         self.draw_edges(c)
         c.writePDFfile(file)
开发者ID:erebuseternal,项目名称:kirky,代码行数:27,代码来源:__init__.py

示例8: Draw

 def Draw(self, file):
     # this simply creates a canvas, draws the interior and exterior and 
     # then exports it as a PDF
     c = canvas.canvas()
     DrawBlock(self.block, c)
     DrawBlock(self.interior, c)
     c.writePDFfile(file)
开发者ID:erebuseternal,项目名称:kirky_devel,代码行数:7,代码来源:__init__.py

示例9: array34

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
开发者ID:gertingold,项目名称:euroscipy16-numpy-tutorial,代码行数:29,代码来源:broadcast.py

示例10: main

def main():
    out_fname = sys.argv[1]
    basedir = '/'.join(os.path.dirname(os.path.realpath(__file__)).split('/')[:-2])
    mm9_methods = {
        'HiFive-Probability':'%s/Analysis/hifive_mm9_ESC_prob_correlations.txt' % basedir, 
        'HiFive-Express':'%s/Analysis/hifive_mm9_ESC_exp_correlations.txt' % basedir, 
        'HiFive-Binning':'%s/Analysis/hifive_mm9_ESC_bin_correlations.txt' % basedir, 
    }
    dist_methods = {
        'HiFive-Probability':'%s/Analysis/hifive_mm9_ESC_probnodist_correlations.txt' % basedir, 
        'HiFive-Express':'%s/Analysis/hifive_mm9_ESC_expnodist_correlations.txt' % basedir, 
        'HiFive-Binning':'%s/Analysis/hifive_mm9_ESC_binnodist_correlations.txt' % basedir, 
    }
    mm9_data = load_data(mm9_methods)
    dist_data = load_data(dist_methods)
    width = 16.8
    spacer = 0.4
    range_width = (width - spacer) / 3.0
    c = canvas.canvas()
    mm9_ranges_img = plot_dataset_ranges(mm9_data, dist_data, range_width)
    c.insert(mm9_ranges_img)
    mm9_overall_img = plot_overall(mm9_data, dist_data, range_width, range_width)
    mm9_overall_img.text(0, range_width, 'b',
                        [text.halign.left, text.valign.top, text.size(-1)])
    c.insert(mm9_overall_img, [trafo.translate(range_width * 2 + spacer, range_width)])
    c.insert(plot_key(range_width / 2, range_width / 2),
             [trafo.translate(range_width * 2.25 + spacer, range_width * 0.25)])
    c.writePDFfile(out_fname)
开发者ID:bxlab,项目名称:HiFive_Paper,代码行数:28,代码来源:hic_distance_cutoff_comparison.py

示例11: paint

 def paint(self, plotitems):
     "creates the layout of the key"
     columndist_pt = unit.topt(self.columndist)
     c = canvas.canvas()
     itemspercolumn = (len(plotitems) + self.columns - 1) // self.columns
     x_pt = 0
     while plotitems:
         subc = self.paintcolumn(plotitems[:itemspercolumn])
         c.insert(subc, [trafo.translate_pt(x_pt, 0)])
         x_pt += unit.topt(subc.bbox().width()) + columndist_pt
         del plotitems[:itemspercolumn]
     if self.keyattrs is not None:
         newc = canvas.canvas()
         newc.draw(c.bbox().enlarged(self.border).path(), self.keyattrs)
         newc.insert(c)
         c = newc
     return c
开发者ID:mjg,项目名称:PyX-svn,代码行数:17,代码来源:key.py

示例12: __init__

 def __init__(self, nsquares):
     self.nsquares = nsquares
     self.corners = deque([np.array([0, 0]), np.array([1, 0]),
                           np.array([1, 1]), np.array([0, 1])])
     self.counter = 1
     self.initialize_pyx()
     self.c = canvas.canvas()
     self.draw()
开发者ID:gertingold,项目名称:euroscipy16-numpy-tutorial,代码行数:8,代码来源:fibonacci.py

示例13: plot_key

def plot_key(width, height):
    c = canvas.canvas()
    w = height / 7.0
    for i, meth in enumerate(methods):
        c.fill(path.rect(1.0, (6 - i) * w - 0.1, 0.2, 0.2), [method_colors[meth]])
        c.text(1.3, (6 - i) * w, "%s" % meth_names[meth],
               [text.halign.left, text.valign.middle, text.size(-3)])
    return c
开发者ID:bxlab,项目名称:HiFive_Paper,代码行数:8,代码来源:fivec_distance_cutoff_comparison.py

示例14: see_frame

 def see_frame(self, file):
     for edge in self.frame.coordinate_vectors:
         edge.weight = edge.pin
     for edge in self.frame.cross_vectors:
         edge.weight = edge.pin
     c = canvas.canvas()
     self.draw_edges(c)
     c.writePDFfile(file)
开发者ID:erebuseternal,项目名称:kirky,代码行数:8,代码来源:__init__.py

示例15: plot_key

def plot_key(width, height):
    c = canvas.canvas()
    step = height / float(len(method_colors))
    for i, meth in enumerate(['HiFive-Probability', 'HiFive-Express', 'HiFive-Binning']):
        c.fill(path.rect(0.2, height - step * (i + 0.5) - 0.1, 0.2, 0.2),
               [method_colors[meth]])
        c.text(0.5, height - step * (i + 0.5), meth, [text.halign.left, text.valign.middle, text.size(-2)])
    return c
开发者ID:bxlab,项目名称:HiFive_Paper,代码行数:8,代码来源:hic_distance_cutoff_comparison.py


注:本文中的pyx.canvas.canvas函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。