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


Python LinePlot.height方法代码示例

本文整理汇总了Python中reportlab.graphics.charts.lineplots.LinePlot.height方法的典型用法代码示例。如果您正苦于以下问题:Python LinePlot.height方法的具体用法?Python LinePlot.height怎么用?Python LinePlot.height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.graphics.charts.lineplots.LinePlot的用法示例。


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

示例1: main

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
def main():
	f = file("Translate1-2004-01-09-g(9.8).txt")
	timex = []
	timey = []
	timez = []
	for line in f:		
		list = line.split(' ')
		timex.append((float(list[0]), float(list[1])))
		timey.append((float(list[0]), float(list[2])))

	drawing = Drawing(400,600)
	
	max_time, _ = timex[len(timex)-1]
	_, max_x = timex[len(timex)-1]	
	
	lineplot_x = LinePlot()	
	lineplot_x.x = max_time+1
	##lineplot_x.x = 50
	lineplot_x.y = max_x+1
	##lineplot_x.y = 50
	lineplot_x.height = 125
	lineplot_x.width = 300	
	lineplot_x.data = [timex]
	drawing.add(lineplot_x)
	
	_, max_y = timey[len(timey)-1]
	lineplot_y = LinePlot()
	lineplot_y.x = max_time+1
	lineplot_y.y = max_y+1
	lineplot_y.height = 125
	lineplot_y.width = 300
	lineplot_y.data = [timey]
	##drawing.add(lineplot_y)
	
##	renderPDF.drawToFile(drawing, 'XVal1VsTime-2004-01-09-g(9.8).pdf', 'XvsTime')
##	_, max_y = timex[len(timey)-1]
##	lineplot_y = LinePlot()	
	
	##write data to files
	file_x = file("xpos.txt", 'w')
	for item in timex:
		str = item.__str__()
		str = str.replace('(', '')
		str = str.replace(')', '')
		str = str.replace(',', '')
		file_x.write(str + '\n')
		
	file_y = file("ypos.txt", 'w')
	for item in timey:
		str = item.__str__()
		str = str.replace('(', '')
		str = str.replace(')', '')
		str = str.replace(',', '')
		file_y.write(str + '\n')
开发者ID:BackupTheBerlios,项目名称:edge-svn,代码行数:56,代码来源:time_pos_extract.py

示例2: test03

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
def test03():
    # 最终太阳黑子图形程序
    from urllib import urlopen
    from reportlab.graphics.shapes import *
    from reportlab.graphics.charts.lineplots import LinePlot
    from reportlab.graphics.charts.textlabels import Label
    from reportlab.graphics import renderPDF

    URL = "http://services.swpc.noaa.gov/text/predicted-sunspot-radio-flux.txt"
    COMMENT_CHARS = "#:"
    drawing = Drawing(400, 200)
    data = []
    for line in urlopen(URL).readlines():
        if not line.isspace() and not line[0] in COMMENT_CHARS:
            data.append([float(n) for n in line.split()])
    pred = [row[2] for row in data]
    high = [row[3] for row in data]
    low = [row[4] for row in data]
    times = [row[0] + row[1] / 12.0 for row in data]
    lp = LinePlot()
    lp.x = 50
    lp.y = 50
    lp.height = 125
    lp.width = 300
    lp.data = [zip(times, pred), zip(times, high), zip(times, low)]
    lp.lines[0].strokeColor = colors.blue
    lp.lines[1].strokeColor = colors.red
    lp.lines[2].strokeColor = colors.green
    drawing.add(lp)
    drawing.add(String(250, 150, "Sunsports", fontSize=14, fillColor=colors.red))
    renderPDF.drawToFile(drawing, "report2.pdf", "Sunsports")
开发者ID:binger233,项目名称:study,代码行数:33,代码来源:21draw.py

示例3: main

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
def main():
    URL = 'http://www.swpc.noaa.gov/ftpdir/weekly/Predict.txt'
    COMMENT_CHARS = '#:'
    
    drawing = Drawing(400, 200)
    data = []
    
    for line in urlopen(URL).readlines():
        if not line.isspace() and not line[0] in COMMENT_CHARS:
            data.append([float(n) for n in line.split()])
            
    pred = [row[2] for row in data]
    high = [row[3] for row in data]
    low = [row[4] for row in data]
    times = [row[0] + row[1]/12.0 for row in data]
       
    lp = LinePlot()
    lp.x = 50
    lp.y = 50
    lp.height = 125
    lp.width = 300
    lp.data = [zip(times, pred), zip(times, high), zip(times, low)]
    lp.lines[0].strokeColor = colors.blue
    lp.lines[1].strokeColor = colors.red
    lp.lines[2].strokeColor = colors.green
    
    drawing.add(lp)
    
    drawing.add(String(250, 150, 'Sunspots', fontSize = 14, fillColor = colors.red))
    
    renderPDF.drawToFile(drawing, 'report.pdf', 'Sunspots')
开发者ID:satiago,项目名称:workplace,代码行数:33,代码来源:main.py

示例4: sample9c

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
        def sample9c():
            lp = LinePlot()
            lp.yValueAxis = LogYValueAxis()
            lp.x += 20
            lp.y += 20
            lp.height = 250
            lp.width = 350
            data = [[(i, float(i)**2.) for i in range(10, 1001, 10)], ]
            data.append([(i, float(i)**3.) for i in range(10, 1001, 10)])
            data.append([(i, float(i)**1.6) for i in range(10, 1001, 10)])
            lp.data = data
            lp.lines.strokeWidth = .2
            lp.lines[0].strokeColor = colors.red
            lp.lines[1].strokeColor = colors.blue
            lp.lines[2].strokeColor = colors.green

            lp.xValueAxis.visibleGrid = 1
            lp.xValueAxis.gridStrokeDashArray = [1, 1]
            lp.yValueAxis.visibleGrid = 1
            lp.yValueAxis.visibleSubTicks = 1
            lp.yValueAxis.visibleSubGrid = 1
            lp.yValueAxis.subTickNum = 4
            lp.yValueAxis.gridStrokeDashArray = [.3, 1]
            lp.yValueAxis.subGridStrokeDashArray = [.15, 1]

            drawing = Drawing(400,300)
            drawing.add(lp)

            return drawing
开发者ID:,项目名称:,代码行数:31,代码来源:

示例5: line_plot

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
 def line_plot(O, xy_max, data, label_font_size):
   if (reportlab is None): return
   from reportlab.graphics.charts.lineplots import LinePlot
   from reportlab.graphics.widgets.markers import makeMarker
   from reportlab.lib import colors
   lp = LinePlot()
   lp.x = 40
   lp.y = 40
   lp.height = 120
   lp.width = 120
   lp.data = [[(0,0),(xy_max,xy_max)], data]
   lp.lines[0].strokeColor = colors.Color(*[0.8]*3)
   lp.lines[0].strokeWidth = 0.5
   lp.lines[1].strokeColor = colors.white
   lp.lines[1].strokeWidth = 0
   lp.lines[1].symbol = makeMarker("Circle")
   lp.lines[1].symbol.strokeWidth = 0.5
   lp.joinedLines = 1
   lp.strokeColor = colors.Color(*[0.8]*3)
   lp.strokeWidth = 1
   lp.xValueAxis.valueMin = 0
   lp.xValueAxis.valueMax = xy_max
   lp.xValueAxis.valueSteps = range(xy_max+1)
   lp.xValueAxis.strokeWidth = 1
   lp.xValueAxis.tickDown = 3
   lp.xValueAxis.labels.fontSize = label_font_size
   lp.yValueAxis.valueMin = 0
   lp.yValueAxis.valueMax = xy_max
   lp.yValueAxis.valueSteps = range(xy_max+1)
   lp.yValueAxis.strokeWidth = 1
   lp.yValueAxis.tickLeft = 3
   lp.yValueAxis.labels.fontSize = label_font_size
   return lp
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:35,代码来源:tst_tardy_eval.py

示例6: _draw_scatter_plot

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
    def _draw_scatter_plot(self, cur_drawing, x_start, y_start,
                           x_end, y_end):
        """Draw a scatter plot on the drawing with the given coordinates."""
        scatter_plot = LinePlot()

        # set the dimensions of the scatter plot
        scatter_plot.x = x_start
        scatter_plot.y = y_start
        scatter_plot.width = abs(x_start - x_end)
        scatter_plot.height = abs(y_start - y_end)

        scatter_plot.data = self.display_info

        scatter_plot.joinedLines = 0

        # set the axes of the plot
        x_min, x_max, y_min, y_max = self._find_min_max(self.display_info)
        scatter_plot.xValueAxis.valueMin = x_min
        scatter_plot.xValueAxis.valueMax = x_max
        scatter_plot.xValueAxis.valueStep = (x_max - x_min) / 10.0

        scatter_plot.yValueAxis.valueMin = y_min
        scatter_plot.yValueAxis.valueMax = y_max
        scatter_plot.yValueAxis.valueStep = (y_max - y_min) / 10.0

        self._set_colors_and_shapes(scatter_plot, self.display_info)

        cur_drawing.add(scatter_plot)
开发者ID:sip958,项目名称:biopython,代码行数:30,代码来源:Comparative.py

示例7: draw

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
def draw():
    '''
    data=[(2007,8,113.2,114.2,112.2),
          (2007,9,112.8,115.8,109.8),
          (2007,10,111.0,116.0,106.0),
          (2007,11,109.8,116.8,102.8),
          (2007,12,107.3,115.3,99.3),
          (2008,1,105.2,114.2,96.2),
          (2008,2,104.1,114.1,94.1),
          (2008,3,99.9,110.9,88.9),
          (2008,4,94.8,106.8,82.8),
          (2008,5,91.2,104.2,78.2)]
          '''
    '''
    #这个是在pdf里画一个 hello word 的例子,
    d=Drawing(100,100)
    s=String(50,50,"hello word",textAnchor="middle")
    d.add(s)
    renderPDF.drawToFile(d,"hello.pdf","A simple PDF file")#renderPDF.drawToFile调用后会把你的pdf文件存到当前目录下一个叫hello.pdf的文件中
    '''
    URL="http://www.swpc.noaa.gov/ftpdir/weekly/Predict.txt"#见364页,这个网址记录的是太阳黑子的全部数据
    COMMENT_CHARS="#:"
    drawing=Drawing(400,200)
    data=[]
    for line in urlopen(URL).readlines():
        #not isspace()是判断 这一行不为空字符串,not line[0] in COMMENT_CHARS是说 在网页里去掉 # 和 . 的部分
        if not line.isspace() and not line[0] in COMMENT_CHARS:
            data.append([float(n) for n in line.split()])
    #print data
    
    pred=[row[2] for row in data]
    high=[row[3] for row in data]
    low=[row[4] for row in data]
    times=[row[0]+row[1]/12.0 for row in data]
    
    lp=LinePlot()
    #设置 x,y,height,width,以及data
    lp.x=50 
    lp.y=50
    lp.height=125
    lp.width=300
    lp.data=[zip(times,pred),zip(times,high),zip(times,low)]
    lp.lines[0].strokeColor = colors.blue
    lp.lines[1].strokeColor = colors.red
    lp.lines[2].strokeColor = colors.green
    
    
    '''
    drawing.add(PolyLine(zip(times,pred),storkeColor=colors.blue))
    drawing.add(PolyLine(zip(times,high),storkeColor=colors.red))
    drawing.add(PolyLine(zip(times,low),storkeColor=colors.green))
    #drawing.add(PolyLine([(10,50),(100,50),(80,80)],storkeColor=colors.red))#这个是直接画一条线
    '''
    drawing.add(lp)
    drawing.add(String(250,150,"SunSpots",fontSize=14,fillColor=colors.red))
    
    renderPDF.drawToFile(drawing,"report.pdf","SunSpots")#renderPDF.drawToFile调用后会把你的pdf文件存到当前目录下一个叫report.pdf的文件中
开发者ID:xlmysjz,项目名称:Python,代码行数:59,代码来源:Drawing.py

示例8: MakePDF

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
def MakePDF(times, list, reportname, pdfname):
    drawing = Drawing(500, 300)
    lp = LinePlot()
    lp.x = 50
    lp.y = 50
    lp.height = 125
    lp.width = 300
    lp.data = [zip(times, list)]
    lp.lines[0].strokeColor = colors.blue
    lp.lines[1].strokeColor = colors.red
    lp.lines[2].strokeColor = colors.green

    drawing.add(lp)
    drawing.add(String(350, 150, reportname, fontSize=14, fillColor=colors.red))

    renderPDF.drawToFile(drawing, pdfname, reportname)
开发者ID:qddegtya,项目名称:AndroidPerformanceTest_Python,代码行数:18,代码来源:Test_File.py

示例9: line_plot

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
def line_plot(data, elements):
    drawing = Drawing(0, 400)  # for indices
    lp = LinePlot()
    lp.x = 0
    lp.y = 50
    lp.height = 300
    lp.width = 600
    lp.data = data
    lp.joinedLines = 1
    lp.lines[0].symbol = makeMarker('FilledCircle')
    lp.lines[1].symbol = makeMarker('Circle')
    lp.lineLabelFormat = '%2.0f'
    lp.strokeColor = colors.black
    lp.xValueAxis.valueMin = 0
    lp.xValueAxis.valueMax = 5
    lp.xValueAxis.valueSteps = [1, 2, 2.5, 3, 4, 5]
    lp.xValueAxis.labelTextFormat = '%2.1f'
    lp.yValueAxis.valueMin = 0
    lp.yValueAxis.valueMax = 7
    lp.yValueAxis.valueSteps = [1, 2, 3, 5, 6]
    drawing.add(lp)
    elements.append(drawing)
开发者ID:prakhar987,项目名称:PDF-Generator-SSAD-Project,代码行数:24,代码来源:views.py

示例10: graphout

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
   def graphout(name, datain,xaxis=None):
       if xaxis is None:
           xaxis=range(datain.size)
       if xlabel is None:
           xlabel = ''
       if ylabel is None:
           ylabel = ''
 
       drawing = Drawing(400, 200)
    # data = [
    #    ((1,1), (2,2), (2.5,1), (3,3), (4,5)),
    #    ((1,2), (2,3), (2.5,2), (3.5,5), (4,6))
    #    ]
       dataview = [tuple([(xaxis[i],datain[i]) for i in range(datain.size)])]
       lp = LinePlot()
       lp.x = 50
       lp.y = 50
       lp.height = 125
       lp.width = 300
       lp.data = dataview
       lp.xValueAxis.xLabelFormat       = '{mmm} {yy}'  
       lp.lineLabels.fontSize           = 6  
       lp.lineLabels.boxStrokeWidth     = 0.5  
       lp.lineLabels.visible            = 1  
       lp.lineLabels.boxAnchor          = 'c'  
    # lp.joinedLines = 1
    # lp.lines[0].symbol = makeMarker('FilledCircle')
    # lp.lines[1].symbol = makeMarker('Circle')
    # lp.lineLabelFormat = '%2.0f'
    # lp.strokeColor = colors.black
    # lp.xValueAxis.valueMin = min(xaxis)
    # lp.xValueAxis.valueMax = max(xaxis)
    # lp.xValueAxis.valueSteps = xaxis
    # lp.xValueAxis.labelTextFormat = '%2.1f'
    # lp.yValueAxis.valueMin = min(datain)
    # lp.yValueAxis.valueMax = max(datain)
    # lp.yValueAxis.valueSteps = [1, 2, 3, 5, 6]
       drawing.add(lp)
       return drawing
开发者ID:meyerson,项目名称:BOUT,代码行数:41,代码来源:pb_draw.py

示例11: test_23_linePlotCharts

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
    def test_23_linePlotCharts(self):
        from reportlab.lib.styles import getSampleStyleSheet
        from reportlab.lib import colors
        from reportlab.lib.units import inch
        from reportlab.platypus import SimpleDocTemplate, Spacer, Paragraph
        from reportlab.pdfbase import pdfmetrics
        from reportlab.graphics.shapes import Drawing
        from reportlab.pdfbase.ttfonts import TTFont
        from reportlab.graphics.charts.lineplots import LinePlot
        from reportlab.graphics.widgets.markers import makeMarker

        pdfmetrics.registerFont(TTFont('chsFont', 'STHeiti Light.ttc'))
        stylesheet = getSampleStyleSheet()

        elements = []
        doc = SimpleDocTemplate("demo.pdf")

        elements.append(Paragraph('<font name="chsFont">JY.zenist.song - 俊毅</font>', stylesheet['Title']))
        elements.append(Spacer(1,1*inch))

        d = Drawing(400,200)
        data = [
            [(1,1), (2,2), (2.5,1), (3,3), (4,5)],
        ]
        lp = LinePlot()
        lp.x = 5
        lp.y = 5
        lp.height = 190
        lp.width = 390
        lp.data = data
        lp.joinedLines = 1
        lp.lines[0].symbol = makeMarker('FilledCircle')
        d.add(lp)

        elements.append(d)

        doc.build(elements)
开发者ID:zenist,项目名称:ZLib,代码行数:39,代码来源:test_pdf.py

示例12: generate_certificate

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
def generate_certificate(elements):
    styles = ParagraphStyle(
        name='Normal',
        fontName='Helvetica-Bold',
        fontSize=15,
        alignment=1,
    )
    elements.append(Spacer(1, 0.5 * inch))
    i = Paragraph(str("candidate performance vs average performance"), styles)
    elements.append(i)
    elements.append(Spacer(1, 0.1 * inch))
    drawing = Drawing(0, 200)  # for indices
    data = [
        (13, 5, 20, 22, 37, 45, 19, 4),
        (14, 6, 21, 23, 38, 46, 20, 5)
    ]  # data for drawing bar graphs
    bc = VerticalBarChart()
    bc.x = 0  # x,y define the left bottom of graph
    bc.y = 0
    bc.height = 150
    bc.width = 300
    bc.data = data
    bc.strokeColor = colors.black
    bc.valueAxis.valueMin = 0
    bc.valueAxis.valueMax = 50
    bc.valueAxis.valueStep = 10
    bc.categoryAxis.labels.boxAnchor = 'ne'
    bc.categoryAxis.labels.dx = 6  # next 3 lines is for naming indices
    bc.categoryAxis.labels.dy = -2
    bc.categoryAxis.labels.angle = 60
    bc.categoryAxis.categoryNames = ['Jan-99', 'Feb-99', 'Mar-99',
                                     'Apr-99', 'May-99', 'Jun-99', 'Jul-99', 'Aug-99']
    drawing.add(bc)
    elements.append(drawing)
    elements.append(Spacer(1, 0.5 * inch))
    drawing = Drawing(0, 175)  # for indices
    lc = HorizontalLineChart()
    lc.x = 0
    lc.y = 10
    lc.height = 150
    lc.width = 300
    lc.data = data
    lc.joinedLines = 1
    catnames = 'Jan Feb Mar Apr May Jun Jul Aug'.split(' ')
    lc.categoryAxis.categoryNames = catnames
    lc.categoryAxis.labels.boxAnchor = 'n'
    lc.valueAxis.valueMin = 0
    lc.valueAxis.valueMax = 60
    lc.valueAxis.valueStep = 15
    lc.lines[0].strokeWidth = 2
    lc.lines[1].strokeWidth = 1.5
    drawing.add(lc)
    elements.append(drawing)
    drawing = Drawing(0, 400)  # for indices
    data = [
        ((1, 1), (2, 2), (2.5, 1), (3, 3), (4, 5)),
        ((1, 2), (2, 3), (2.5, 2), (3.5, 5), (4, 6))
    ]
    elements.append(Spacer(1, 0.1 * inch))
    i = Paragraph(str("candidate performance vs average performance"), styles)
    elements.append(i)
    elements.append(Spacer(1, 0.1 * inch))
    lp = LinePlot()
    lp.x = 0
    lp.y = 50
    lp.height = 300
    lp.width = 600
    lp.data = data
    lp.joinedLines = 1
    lp.lines[0].symbol = makeMarker('FilledCircle')
    lp.lines[1].symbol = makeMarker('Circle')
    lp.lineLabelFormat = '%2.0f'
    lp.strokeColor = colors.black
    lp.xValueAxis.valueMin = 0
    lp.xValueAxis.valueMax = 5
    lp.xValueAxis.valueSteps = [1, 2, 2.5, 3, 4, 5]
    lp.xValueAxis.labelTextFormat = '%2.1f'
    lp.yValueAxis.valueMin = 0
    lp.yValueAxis.valueMax = 7
    lp.yValueAxis.valueSteps = [1, 2, 3, 5, 6]
    drawing.add(lp)
    elements.append(drawing)
    elements.append(Spacer(1, 0.1 * inch))
    drawing = Drawing(100, 350)
    pc = Pie()
    pc.x = 65
    pc.y = 15
    pc.width = 300
    pc.height = 300
    pc.data = [10, 20, 30, 40, 50, 60]
    pc.labels = ['a', 'b', 'c', 'd', 'e', 'f']
    pc.slices.strokeWidth = 0.5
    pc.slices[3].popout = 10
    pc.slices[3].strokeWidth = 2
    pc.slices[3].strokeDashArray = [2, 2]
    pc.slices[3].labelRadius = 1.75
    pc.slices[3].fontColor = colors.red
    drawing.add(pc)
    elements.append(drawing)
    elements.append(Spacer(1, 0.7 * inch))
#.........这里部分代码省略.........
开发者ID:veeruravi,项目名称:pdf-generator,代码行数:103,代码来源:backup.py

示例13: generate_certificate

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
def generate_certificate(elements):
    style = TableStyle([('TEXTALIGN', (0, 0), (-1, -1), 'CENTER'),
                        ('TEXTCOLOR', (0, 0), (-1, -1), colors.red),
                        ('VALIGN', (0, 0), (0, -1), 'TOP'),
                        ('INNERGRID', (0, 0), (-1, -1), 0.50, colors.red),
                        ('BOX', (0, 0), (-1, -1), 0.50, colors.green),
                        ('BACKGROUND', (0, 0), (-1, -1), colors.blue),
                        ])
    s = getSampleStyleSheet()
    s = s["BodyText"]
    s.wordWrap = "RGB"
    styles = ParagraphStyle(
        name='Normal',
        fontName='Helvetica-Bold',
        fontSize=15,
        alignment=1,
    )
    elements.append(Spacer(1, 0.5 * inch))
    i = Paragraph(str("candidate performance vs average performance"), styles)
    elements.append(i)
    elements.append(Spacer(1, 0.1 * inch))
    drawing = Drawing(0, 200)  # for indices
    data = [
        (13, 5, 20, 22, 37, 45, 19, 4),
        (14, 6, 21, 23, 38, 46, 20, 5)
    ]  # data for drawing bar graphs
    bc = VerticalBarChart()
    bc.x = 0  # x,y define the left bottom of graph
    bc.y = 0
    bc.height = 150
    bc.width = 300
    bc.data = data
    bc.strokeColor = colors.black
    bc.valueAxis.valueMin = 0
    bc.valueAxis.valueMax = 50
    bc.valueAxis.valueStep = 10
    bc.categoryAxis.labels.boxAnchor = 'ne'
    bc.categoryAxis.labels.dx = 6  # next 3 lines is for naming indices
    bc.categoryAxis.labels.dy = -2
    bc.categoryAxis.labels.angle = 60
    bc.categoryAxis.categoryNames = ['Jan-99', 'Feb-99', 'Mar-99',
                                     'Apr-99', 'May-99', 'Jun-99', 'Jul-99', 'Aug-99']
    drawing.add(bc)
    elements.append(drawing)
    elements.append(Spacer(1, 0.5 * inch))
    drawing = Drawing(0, 175)  # for indices
    lc = HorizontalLineChart()
    lc.x = 0
    lc.y = 10
    lc.height = 150
    lc.width = 300
    lc.data = data
    lc.joinedLines = 1
    catNames = 'Jan Feb Mar Apr May Jun Jul Aug'.split(' ')
    lc.categoryAxis.categoryNames = catNames
    lc.categoryAxis.labels.boxAnchor = 'n'
    lc.valueAxis.valueMin = 0
    lc.valueAxis.valueMax = 60
    lc.valueAxis.valueStep = 15
    lc.lines[0].strokeWidth = 2
    lc.lines[1].strokeWidth = 1.5
    drawing.add(lc)
    elements.append(drawing)
    drawing = Drawing(0, 400)  # for indices
    data = [
        ((1, 1), (2, 2), (2.5, 1), (3, 3), (4, 5)),
        ((1, 2), (2, 3), (2.5, 2), (3.5, 5), (4, 6))
    ]
    elements.append(Spacer(1, 0.1 * inch))
    i = Paragraph(str("candidate performance vs average performance"), styles)
    elements.append(i)
    elements.append(Spacer(1, 0.1 * inch))
    lp = LinePlot()
    lp.x = 0
    lp.y = 50
    lp.height = 300
    lp.width = 600
    lp.data = data
    lp.joinedLines = 1
    lp.lines[0].symbol = makeMarker('FilledCircle')
    lp.lines[1].symbol = makeMarker('Circle')
    lp.lineLabelFormat = '%2.0f'
    lp.strokeColor = colors.black
    lp.xValueAxis.valueMin = 0
    lp.xValueAxis.valueMax = 5
    lp.xValueAxis.valueSteps = [1, 2, 2.5, 3, 4, 5]
    lp.xValueAxis.labelTextFormat = '%2.1f'
    lp.yValueAxis.valueMin = 0
    lp.yValueAxis.valueMax = 7
    lp.yValueAxis.valueSteps = [1, 2, 3, 5, 6]
    drawing.add(lp)
    elements.append(drawing)
    elements.append(Spacer(1, 0.1 * inch))
    drawing = Drawing(100, 350)
    pc = Pie()
    pc.x = 65
    pc.y = 15
    pc.width = 300
    pc.height = 300
    pc.data = [10, 20, 30, 40, 50, 60]
#.........这里部分代码省略.........
开发者ID:prakhar987,项目名称:PDF-Generator-SSAD-Project,代码行数:103,代码来源:views.py

示例14: make_graphs

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
  def make_graphs(self,canvas=None,left_margin=None):#text=None):
    from reportlab.graphics import renderPDF
    from reportlab.lib.pagesizes import letter
    from reportlab.graphics.shapes import Drawing,String
    from reportlab.graphics.charts.legends import Legend
    from reportlab.graphics.charts.lineplots import LinePlot
    from reportlab.graphics.widgets.markers import makeMarker
    from reportlab.lib import colors
    from reportlab.lib.units import inch
    #help(colors)

    self.framework = {4:dict(status=SpotClass.SPINDLE,color=colors.black),
                      5:dict(status=SpotClass.OVERLAP,color=colors.limegreen),
                      6:dict(status=SpotClass.OUTLIER,color=colors.greenyellow),
                      7:dict(status=SpotClass.ICE,color=colors.skyblue),
    }


    # set size and position
    width,height = letter
    #letter_landscape = (width,height)
    plot_dim = 3.0*inch

    # construct scatter plot
    plot_dxdy_pos = (left_margin*inch,height - plot_dim - 0.5*inch)
    plot_dxdy = LinePlot()
    plot_dxdy.data = self.plot_dxdy_data

    std_colors = {0:colors.darkred, 1:colors.red, 2:colors.salmon}
    for key in std_colors.keys():
      plot_dxdy.lines[key].strokeColor = None
      plot_dxdy.lines[key].symbol = makeMarker('Circle')
      plot_dxdy.lines[key].symbol.strokeColor = None
      plot_dxdy.lines[key].symbol.fillColor = std_colors[key]
      plot_dxdy.lines[key].symbol.size = 1.2

    for key in self.framework.keys():
      plot_dxdy.lines[key].strokeColor = None
      plot_dxdy.lines[key].symbol = makeMarker('Circle')
      plot_dxdy.lines[key].symbol.strokeColor = None
      plot_dxdy.lines[key].symbol.fillColor = self.framework[key]["color"]
      plot_dxdy.lines[key].symbol.size = 1.2

    plot_dxdy.lines[3].strokeColor = None
    plot_dxdy.lines[3].symbol = makeMarker('Circle')
    plot_dxdy.lines[3].symbol.strokeColor = colors.blue
    plot_dxdy.lines[3].symbol.fillColor = None
    plot_dxdy.lines[3].symbol.strokeWidth = 0.6
    plot_dxdy.lines[3].symbol.size = plot_dim*(self.sqrtr2)
    #print plot_dxdy.lines[3].symbol.getProperties()
    plot_dxdy.width = plot_dim
    plot_dxdy.height = plot_dim
    plot_dxdy.xValueAxis.valueMax = 1.0
    plot_dxdy.xValueAxis.valueMin = -1.0
    plot_dxdy.xValueAxis.joinAxis = plot_dxdy.yValueAxis
    plot_dxdy.xValueAxis.joinAxisMode = 'value'
    plot_dxdy.xValueAxis.joinAxisPos = -1.0
    plot_dxdy.yValueAxis.valueMax = 1.0
    plot_dxdy.yValueAxis.valueMin = -1.0
    d_dxdy = Drawing(plot_dim,plot_dim)
    d_dxdy.add(plot_dxdy)

    # construct cdf plot
    plot_cdf_pos = (left_margin*inch, height - 2.0*(plot_dim + 0.5*inch))
    plot_cdf = LinePlot()
    plot_cdf.data = self.plot_cdf_data
    plot_cdf.lines[0].strokeColor = colors.blue

    for key in std_colors.keys():
      plot_cdf.lines[key+1].strokeColor = None
      plot_cdf.lines[key+1].symbol = makeMarker('Circle')
      plot_cdf.lines[key+1].symbol.strokeColor = None
      plot_cdf.lines[key+1].symbol.fillColor = std_colors[key]
      plot_cdf.lines[key+1].symbol.size = 1.2

    if (len(self.plot_cdf_data) == 5):
      plot_cdf.lines[4].strokeColor = colors.green
    plot_cdf.width = plot_dim
    plot_cdf.height = plot_dim
    plot_cdf.xValueAxis.valueMax = 1.0
    plot_cdf.xValueAxis.valueMin = 0.0
    plot_cdf.yValueAxis.valueMax = 1.0
    plot_cdf.yValueAxis.valueMin = 0.0
    d_cdf = Drawing(plot_dim,plot_dim)
    d_cdf.add(plot_cdf)

    # construct pdf plot
    plot_pdf_pos = (left_margin*inch, height - 3.0*(plot_dim + 0.5*inch))
    plot_pdf = LinePlot()
    plot_pdf.data = self.plot_pdf_data
    plot_pdf.lines[1].strokeColor = colors.blue
    plot_pdf.lines[0].strokeColor = None
    plot_pdf.lines[0].symbol = makeMarker('Circle')
    plot_pdf.lines[0].symbol.strokeColor = colors.red
    plot_pdf.lines[0].symbol.size = 1
    plot_pdf.width = plot_dim
    plot_pdf.height = plot_dim
    plot_pdf.xValueAxis.valueMax = 1.0
    plot_pdf.xValueAxis.valueMin = 0.0
    d_pdf = Drawing(2*plot_dim,plot_dim)
#.........这里部分代码省略.........
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:103,代码来源:outlier_detection.py

示例15: dategraph

# 需要导入模块: from reportlab.graphics.charts.lineplots import LinePlot [as 别名]
# 或者: from reportlab.graphics.charts.lineplots.LinePlot import height [as 别名]
    def dategraph(self,lxydata,tmin=None,tmax=None): # list of (label, [x,yarr]) with x in seconds
        maxX = lxydata[0][1][0][0]
        maxY = 1.
        minX = maxX
        minY = -1
        for label,xyarr in lxydata:
            xarr = [x for (x,y) in xyarr]
            yarr = [y for (x,y) in xyarr]
            maxY = max(maxY, max(yarr))
            minY = min(minY, min(yarr))
            maxX = max(maxX, max(xarr))
            minX = min(minX, min(xarr))
        if not tmin is None:
            minX = tmin
        if not tmax is None:
            maxX = tmax
        lxydata.append(('CritMax',[[minX,1.],[maxX,1.]]))
        lxydata.append(('CritMin',[[minX,-1.],[maxX,-1.]]))

        drawing = Drawing(self.PAGE_WIDTH-150, 200)
        lc = LinePlot()
        lc.x = 30
        lc.y = 50
        lc.height = 125
        lc.width = self.PAGE_WIDTH-150-30
        lc.data = [xy for (l,xy) in lxydata]
        datalabels = [ l for (l,xy) in lxydata]

        lc.xValueAxis.valueMin = minX
        lc.xValueAxis.valueMax = maxX
        lc.xValueAxis.valueStep = int((maxX-minX)/5)
        lc.xValueAxis.labelTextFormat = dateformatter # Use the formatter
        lc.xValueAxis.visibleGrid           = True
        lc.xValueAxis.gridStrokeWidth = .5
        lc.xValueAxis.gridStrokeColor = colors.darkgrey
        lc.xValueAxis.subTickNum = 1
        lc.xValueAxis.subGridStrokeWidth = .25
        lc.xValueAxis.subGridStrokeColor = colors.lightgrey
        lc.xValueAxis.visibleSubGrid = True

        lc.yValueAxis.valueMin = minY
        lc.yValueAxis.valueMax = maxY
        lc.yValueAxis.valueStep = .25
        if (maxY-minY)>2:
            lc.yValueAxis.valueStep = .5
        if (maxY-minY)>4:
            lc.yValueAxis.valueStep = 1.
        lc.yValueAxis.visibleGrid           = True
        lc.yValueAxis.gridStrokeWidth = .5
        lc.yValueAxis.gridStrokeColor = colors.darkgrey
        lc.yValueAxis.subTickNum = 1
        lc.yValueAxis.subGridStrokeWidth = .25
        lc.yValueAxis.subGridStrokeColor = colors.lightgrey
        lc.yValueAxis.visibleSubGrid = True

        for x in range(len(lc.data)):
            lc.lines[x].strokeColor = self.colors[x]
            lc.lines[x].name = datalabels[x]
            if len(lc.data[x]) ==1:
                lc.lines[x].symbol = makeMarker('FilledCircle') # added to make filled circles.
            lc.lines[x].strokeWidth = 2
            if lc.lines[x].name == 'CritMin' or lc.lines[x].name == 'CritMax': # distinguish min/max
                lc.lines[x].strokeColor = self.colors[0]
                lc.lines[x].strokeDashArray = (5, 1)

        self.addLabels(drawing,ylabel="geschaalde waarde")
        drawing.add(lc)
        drawing.add(self.addAutoLegend(lc,(lc.x,lc.y),len(lc.data)))
        return drawing
开发者ID:jhuguetn,项目名称:WAD_Python,代码行数:71,代码来源:reporter.py


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