Esempio n. 1
0
def cartesiano(datos):
    alto = datos["alto"]
    ancho = datos["ancho"]
    data = datos["data"]
    colores = datos["colores"]
    labels = datos["labels"]
    menor = datos["rango"][0]
    mayor = datos["rango"][1]

    grafico = ScatterPlot()
    grafico.x = 20
    grafico.y = 40
    grafico.width = ancho
    grafico.height = alto
    grafico.data = data
    grafico.joinedLines = 1
    grafico.lineLabelFormat = None
    grafico.outerBorderOn = 0
    grafico.outerBorderColor = None
    grafico.background = None
    for i in range(len(colores)):
        color = colors.HexColor(colores[i])
        grafico.lines[i].strokeColor = color
        grafico.lines[i].symbol.strokeColor = color
        grafico.lines[i].symbol.fillColor = color
        grafico.lines[i].symbol.strokeWidth = 0
    grafico.xLabel=labels["x"]
    grafico.xValueAxis.labels.fontSize = FONTSIZE
    grafico.xValueAxis.labelTextFormat = lambda x: " Hace\n%d días" % abs(x)
    grafico.xValueAxis.valueStep = 10
    grafico.xValueAxis.labels.dy = -5
    grafico.xValueAxis.strokeColor = colors.black
    grafico.xValueAxis.strokeWidth = 1
    grafico.xValueAxis.tickDown = 5
    grafico.yLabel=labels["y"]
    grafico.yValueAxis.labels.fontSize = FONTSIZE
    grafico.yValueAxis.labelTextFormat = "%d"
    grafico.yValueAxis.labels.dx = -5
    grafico.yValueAxis.strokeColor = colors.black
    grafico.yValueAxis.strokeWidth = 1
    grafico.yValueAxis.tickLeft = 5
    grafico.yValueAxis.valueStep = 1
    grafico.yValueAxis.valueMin = menor
    grafico.yValueAxis.valueMax = mayor
    return crearDrawing(grafico)
Esempio n. 2
0
def scatter_plot_2(final_dis_clock, xname, yname):
    drawing = Drawing(400, 300)

    chart = ScatterPlot()

    chart.width = 450
    chart.height = 350

    chart.x = 32
    chart.y = 26

    chart.data = [final_dis_clock]

    chart.joinedLines = 0
    chart.fillColor = color03
    chart.lineLabelFormat = None
    chart.lineLabels.fontName = 'Helvetica'

    lab = Label()
    lab.setOrigin(130, 260)

    chart.xValueAxis.avoidBoundFrac = 1
    chart.xValueAxis.visibleGrid = 1
    chart.xValueAxis.tickDown = 2
    chart.xValueAxis.labels.fontName = 'Helvetica'
    chart.xValueAxis.labels.fontSize = 10
    chart.xValueAxis.labelTextFormat = '%d'
    chart.leftPadding = -32

    chart.xLabel = xname
    chart.xValueAxis.forceZero = 1

    chart.yValueAxis.avoidBoundFrac = 1
    chart.yValueAxis.visibleGrid = 1
    chart.yValueAxis.tickLeft = 2
    chart.yValueAxis.labels.fontName = 'Helvetica'
    chart.yValueAxis.labels.fontSize = 10
    chart.yValueAxis.labelTextFormat = '%s'

    chart.yValueAxis.valueMin = 0.0
    chart.yValueAxis.valueStep = 3.0
    chart.yValueAxis.valueMax = 9.0

    chart.yLabel = yname
    chart.yLabel.center(10)
    chart.yValueAxis.forceZero = 0

    # Title = Label()
    # Title.fontName = 'Helvetica-Bold'
    # Title.fontSize = 10
    # Title.x = 100
    # Title.y = 550
    # Title._text = 'This is just a test chart'
    # Title.maxWidth = 20
    # Title.height = 100
    # Title.textAnchor = 'middle'

    # legend = Legend()
    # legend.colorNamePairs = [(color01, 'Widgets'), (color02, 'Sprockets')]
    # legend.fontName = 'Helvetica'
    # legend.fontSize = 8
    # legend.x = 470
    # legend.y = 470
    # legend.dxTextSpace = 4
    # legend.dy = 7
    # legend.dx = 7
    # legend.deltay = 4
    # legend.alignment = 'right'

    drawing.add(chart)
    return drawing