[reportlab-users] plotting points on a jpg
robin at reportlab.com
Thu Nov 10 05:36:59 EST 2005
Britt Hibbert wrote:
> Hi All,
> I am trying to plot points, along with labels, on a jpg image. I have a graph that is split into four quadrants, and have to place points in various sections of these quadrants based on specific data. As an example of this, I have been looking at how the pdfmap tool does this.
> I am planning on using a jpg image as a background and plotting points on top of this jpg, using the canvas object. Before I get too far into this, I am just wondering if there is a higher level way of doing this. My use of reportlab so far has been limited to Platypus and Flowables, so I am a little wary of diving into canvas objects and then integrating this with my current use of flowables. Is there a higher level way of doing what I need, or examples posted somewhere of how to do this?
> Thanks in advance for any help
> Britt Hibbert
You probably want to make a Drawing which is the same size as the jpeg; you can
then add the various bits in the __init__ method. Drawings are already flowables
so they know how to draw themselves.
This is the sort of thing that can be knocked together fairly swiftly
#Autogenerated by ReportLab guiedit do not edit
from reportlab.graphics.widgets.markers import Marker
from reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, Image, Line
from reportlab.lib.colors import red, blue, green
self.background = Image(0,0,self.width,self.height,'bgsample.jpg')
for x,y in self._data:
m = Marker()
m.kind = 'StarFive'
m.x = x
m.y = y
m.size = 7
m.fillColor = green
if __name__=="__main__": #NORUNTESTS
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 5672 bytes
Desc: not available
Url : http://two.pairlist.net/pipermail/reportlab-users/attachments/20051110/40d81e1e/example-0001.obj
More information about the reportlab-users