[reportlab-users] How to mark a specific point in line plot?

189 views
Skip to first unread message

K 華

unread,
Nov 20, 2015, 4:24:07 AM11/20/15
to reportl...@lists2.reportlab.com
hi,  I made my PDF with reportlab recent days, and draw a line plot in my report
now I need to mark  max/min point  in my  line  plot, and my  code  is like  below

lp.lines[0].symbol = makeMarker('FilledCircle')
lp.lines[0].strokeDashArray = [5, 1]
 lp.lines[(0,2)].symbol.fillColor = colors.green

however  it  doesn't  work  at  the  point(0, 2) filled  green
did I  use  the  wrong  way  to  achieve  target?  or  is  there  another  way  to  make this  target working?
thanks for your help

KK
2015/11/20

Robin Becker

unread,
Nov 20, 2015, 5:24:13 AM11/20/15
to reportlab-users
On 20/11/2015 09:24, K 華 wrote:
> hi, I made my PDF with reportlab recent days, and draw a line plot in my reportnow I need to mark max/min point in my line plot, and my code is like below
> lp.lines[0].symbol = makeMarker('FilledCircle')lp.lines[0].strokeDashArray = [5, 1] lp.lines[(0,2)].symbol.fillColor = colors.green
>
> however it doesn't work at the point(0, 2) filled greendid I use the wrong way to achieve target? or is there another way to make this target working?thanks for your help
> KK2015/11/20
.......

I think this is a simple deficiency in the code; we use either a global symbol
or a row symbol if present, but don't look at the row,column symbol definitions.
--
Robin Becker
_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
https://pairlist2.pair.net/mailman/listinfo/reportlab-users

Robin Becker

unread,
Nov 20, 2015, 6:48:22 AM11/20/15
to reportlab-users
On 20/11/2015 09:24, K 華 wrote:
> hi, I made my PDF with reportlab recent days, and draw a line plot in my reportnow I need to mark max/min point in my line plot, and my code is like below
> lp.lines[0].symbol = makeMarker('FilledCircle')lp.lines[0].strokeDashArray = [5, 1] lp.lines[(0,2)].symbol.fillColor = colors.green
>
> however it doesn't work at the point(0, 2) filled greendid I use the wrong way to achieve target? or is there another way to make this target working?thanks for your help
> KK2015/11/20
....


I did some hacks to the code and attach the versuion of lineplots.py that I
used; then the following code works as expected.

from reportlab.graphics.widgets.markers import makeMarker, Marker
from reportlab.graphics.widgetbase import Widget
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin
from reportlab.graphics.charts.lineplots import LinePlot
from reportlab.lib.colors import green, blue

class Drawing_000(_DrawingEditorMixin,Drawing):
def __init__(self,width=400,height=200,*args,**kw):
Drawing.__init__(self,width,height,*args,**kw)
self._add(self,LinePlot(),name='chart',validate=None,desc=None)
self.chart.lines[0].symbol = makeMarker('FilledCircle')
self.chart.lines[(0, 1)].symbol= makeMarker('FilledSquare')
self.chart.lines[(0, 1)].symbol.size=10
self.chart.lines[(0, 1)].symbol.fillColor = green
self.chart.lines[(0, 1)].symbol.strokeColor = blue
self.chart.lines[(0, 1)].symbol.strokeWidth = 1

if __name__=="__main__": #NORUNTESTS
Drawing_000().save(formats=['pdf'],outDir='.',fnRoot=None)


please try this code and see if it works for you.
--
Robin Becker
lineplots.py

K 華

unread,
Nov 23, 2015, 3:22:18 AM11/23/15
to reportlab-users
It works well, thanks a lot!!

Now I have another question, 
I know that "lineLabelFormat" display all values on lineplot, and "lineLabels[(0, 2)]"  can set one of values' attribute.
but how to display specific value or fonts on the marked point?

thanks

KK
2015/11/23


To: reportl...@lists2.reportlab.com
From: ro...@reportlab.com
Date: Fri, 20 Nov 2015 11:48:28 +0000
Subject: Re: [reportlab-users] How to mark a specific point in line plot?
Reply all
Reply to author
Forward
0 new messages