I have six png figures that I want to combine into a single high resolution figure using the following script:
from svgutils.compose import *
os.system("python pngtosvg.py")
def new_tile(self, ncols, nrows):
dx = self.width.to('px').value/ncols
dy = self.height.to('px').value/nrows
ix, iy = 0, 0
for el in self:
el.move(dx*ix, dy*iy)
ix += 1
if ix >= ncols:
ix = 0
iy += 1
if iy > nrows:
break
return self
Figure.tile = new_tile
scale_factor = 2.
myfigure = Figure("20cm", "13.7cm",
SVG("figure_1.svg").scale(scale_factor),
SVG("figure_2.svg").scale(scale_factor),
SVG("figure_3.svg").scale(scale_factor),
SVG("figure_4.svg").scale(scale_factor),
SVG("figure_5.svg").scale(scale_factor),
SVG("figure_6.svg").scale(scale_factor)
).tile(1, 6)
myfigure.save('figure.svg')
os.system('inkscape --export-png=figure.png figure.svg --export-background=white --export-area-drawing')
os.system("rm /home/username/Desktop/*.svg")
The problem is: Despite the high resolution of individual figures 1 through 6, the resolution of the final combined figure is so low that I can hardly read legends and axes titles. Do you know how to modify my code or probably work with a better package than svgutils to get the best resolution when combining my png figures?