Jupyter notebook how to scale an svg image?

Viewed 153

I am trying and failing to load an svg image into a jupyter notebook and scaling up the dimensions.

This is what I have that displays a correct image:

pathlib.Path("Documentation").mkdir(parents=True, exist_ok=True)
image_path = os.path.join("Documentation", "SphereGrid")
c.writeSVGfile(image_path)

svg_file = image_path + '.svg'
display(SVG(image_path + ".svg"))

Which shows this:

enter image description here

That's super tiny.

I tried scaling it up like this:

svg_file = image_path + '.svg'
import svgutils
svg = svgutils.transform.fromfile(svg_file)
original = svgutils.compose.SVG(svg_file)
original.scale(10.0)
original.moveto(-100.0, -10.0)

new_svg = svgutils.compose.Figure(float(100) * 10.0,
                                  float(100) * 10.0, original)
new_svg.save(svg_file)

display(SVG(image_path + ".svg"))

But that gives this:

enter image description here

Now the figure is the correct size but it's cropped.

0 Answers
Related