I want to concatenate two SVG files into one. This is done successfully by the code below.
I create the combined SVG using the code below. If I then delete the graph1 SVG (manually, after some time), it also gets deleted from the combined SVG. Copying the combined SVG does not resolve the issue. It seems like the combined SVG is a shallow copy of both graph.svg and graph2.svg.
How do i resolve this issue? I want the combined SVG to be independent of the other SVG files.
import svgwrite
# Create a new SVG file
dwg = svgwrite.Drawing('combined.svg')
# Add first image (graph1.svg) to the SVG at position (0, 0)
image1 = svgwrite.image.Image('graph1.svg', insert=(0, 0), size=("300px", "300px"))
dwg.add(image1)
# Add second image (graph2.svg) to the SVG at position (300, 0)
image2 = svgwrite.image.Image('graph2.svg', insert=("300px", 0), size=("300px", "300px"))
dwg.add(image2)
# Set SVG width and height to accommodate both images
dwg['width'] = '600px'
dwg['height'] = '300px'
# Save the combined SVG file
dwg.save()