我想设置与x ax平行的参考线与数据数组中第一个数据的y值。 我在线图中获得第一条记录的位置时遇到问题。我试过scale()但是没有正确地进行缩放。有什么想法吗?
我试过这个:
sensor_readings = [(1425294710, 4187L), (1425375419, 4181L), (1425456126, 4188L), (1425536836, 4209L), (1425617542, 4204L)]
reportChart = GridLinePlot()
reportChart.xValueAxis = XValueAxis()
width = pagesizes.letter[0] - 4*cm
height = pagesizes.letter[1] - 7*cm
reportChart.lines.strokeWidth = 0
reportChart.x = cm
reportChart.y = cm
reportChart.height = height
reportChart.width = width
reportChart.joinedLines = 0
reportChart.data = res_graph_data
reportChart.background.strokeColor = colors.gray
reportChart.lineLabels.fontSize = 6
reportChart.lineLabels.boxStrokeWidth = 0.5
reportChart.lineLabels.visible = 1
reportChart.lineLabels.boxAnchor = 'c'
reportChart.lineLabels.angle = 0
reportChart.lineLabelNudge = 10
reportChart.yValueAxis.labels.fontName = 'DroidSans'
reportChart.yValueAxis.tickRight = 0
reportChart.yValueAxis.maximumTicks = 10
reportChart.yValueAxis.tickLeft = 3
reportChart.yValueAxis.valueMax = None
reportChart.yValueAxis.valueMin = None
reportChart.yValueAxis.rangeRound = 'both'
reportChart.yValueAxis.valueSteps = None
reportChart.yValueAxis.valueStep = None
reportChart.yValueAxis.forceZero = 0
reportChart.yValueAxis.labels.fontSize = 7
reportChart.yValueAxis.labels.dy = 0
reportChart.yValueAxis.avoidBoundFrac = 0.1
reportChart.yValueAxis.requiredRange = 1
reportChart.xValueAxis.labelTextFormat = convert_seconds
reportChart.xValueAxis.labels.fontName = 'DroidSans'
reportChart.xValueAxis.labels.fontSize = 7
reportChart.xValueAxis.valueSteps = None
reportChart.xValueAxis.gridStrokeWidth = 0.25
reportChart.xValueAxis.labels.angle = 90
reportChart.xValueAxis.maximumTicks = 20
reportChart.xValueAxis.tickDown = 3
reportChart.xValueAxis.minimumTickSpacing = 10
reportChart.xValueAxis.visibleGrid = 0
reportChart.xValueAxis.gridEnd = 0
reportChart.xValueAxis.gridStart = 0
reportChart.xValueAxis.labels.angle = 45
reportChart.xValueAxis.labels.boxAnchor = 'e'
reportChart.xValueAxis.labels.dx = 0
reportChart.xValueAxis.labels.dy = -5
readingChart.xValueAxis.valueMin = datetime_min
readingChart.xValueAxis.valueMax = datetime_max
readingChart.xValueAxis.configure([sensor_readings])
readingChart.yValueAxis.configure([sensor_readings])
readingChart.joinedLines = 1
readingDrawing.add(readingChart)
reference_axe = XValueAxis()
pos_x = readingChart.x
pos_y = readingChart.yValueAxis.scale(sensor_readings[0][1])
reference_axe.setPosition(pos_x, pos_y, width)
reference_axe.strokeColor = colors.green
reference_axe.valueMin = datetime_min
reference_axe.valueMax = datetime_max
readingDrawing.add(reference_axe)
story.append(readingDrawing)
story.append(PageBreak())
这是我想要实现的目标: desired reference line