pythongraphics

Python tool(s) to make drawings using dimensionful units


I'm going to make a camera calibration grid of dots (like this one), and it seems like I could do it almost trivially using pyplot.scatter, except that I want to be able to specify the locations and sizes of the dots in terms of centimeters. I need to know the physical sizes and locations of the dots in order to do the camera calibration.

Is there a python module that allows one to programatically define a drawing, specifying distances in terms of physical lengths (centimeters etc.), and allows exporting into a format that will print at the specified size (pdf maybe)?

So far neither matplotlib nor svgfig seem to provide dimensionful sizes.


Solution

  • Pyx works for me! It has a units module so that

    import pyx
    pyx.unit.set(defaultunit="cm")
    c=pyx.canvas.canvas()
    c.fill(pyx.path.circle(1,2,0.25))
    c.writePDFfile('filename')
    

    draws a 0.25cm radius circle, 1cm to the right and 2cm above the origin (which is in the lower left hand corner of the page)