You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
5.0 KiB
5.0 KiB
In [1]:
!pip install svgwrite
Defaulting to user installation because normal site-packages is not writeable Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting svgwrite Downloading https://www.piwheels.org/simple/svgwrite/svgwrite-1.4.1-py3-none-any.whl (66 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 67.0/67.0 KB 2.3 MB/s eta 0:00:00 Installing collected packages: svgwrite Successfully installed svgwrite-1.4.1
In [9]:
import svgwrite from IPython.core.display import SVG, display dwg = svgwrite.Drawing('test.svg', profile='tiny', size=(595, 842) ) dwg.add(dwg.line((0, 0), (10, 50), stroke=svgwrite.rgb(10, 10, 16, '%'))) dwg.add(dwg.text('Test', insert=(0, 0.2))) dwg.save() display(SVG(filename=f'test.svg'))
In [41]:
import svgwrite from svgwrite import cm, mm width = 210 height = 297 rows = 6 columns = 4 cell_size = (width/columns, height/rows) color = svgwrite.rgb(0,0,0, '%') background = svgwrite.rgb(100,95,95,'%') sheet = svgwrite.Drawing('map.svg', profile='tiny', size=(width * mm, height * mm)) # sheet.add(sheet.rect((0,0), (width * mm, height * mm), fill=background)) grid = sheet.add(sheet.g(id='grid', stroke='gainsboro')).dasharray([10, 10]) for row in range(rows + 1): y = cell_size[1] * row grid.add(sheet.line((0, y * mm), (width * mm, y * mm))) for col in range(columns + 1): x = cell_size[0] * col grid.add(sheet.line((x * mm, 0), (x * mm,height * mm))) sheet.save() display(SVG(filename=f'map.svg'))
In [ ]: