question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SVGFigure does not set width and height element if created directly

See original GitHub issue

Width and height aren’t correctly set in the XML if transform.SVGFigure is created directly:

import svgutils
svgutils.transform.SVGFigure("10cm", "16cm").to_str()

prints

b'<?xml version=\'1.0\' encoding=\'ASCII\' standalone=\'yes\'?>\n<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"/>\n'

This code is used in the tutorial:

https://github.com/btel/svg_utils/blob/4abf7fb18cea0da04b6b2a0bcacbec5daded1662/docs/source/tutorials/scripts/fig_final.py#L5

Therefore I expect that this is not an intended behavior.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
akhmerovcommented, Dec 9, 2021

I observed this both on 0.3.4 and master (4abf7fb)

0reactions
btelcommented, Sep 27, 2022

indeed we don’t set the SVG tag attributes when width or height is an integer/string

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the svgutils.transform.SVGFigure function in ... - Snyk
import svgutils.transform as sg import sys #create new SVG figure fig = sg. ... SVGFigure(self.width, self.height) element.append(self) svgstr ...
Read more >
SVG element width and height set in html but appearing as 0 0 ...
One of the reasons why SVG file is rendered on front-end with zero height and width is missing <svg> tag attributes "height" and...
Read more >
Source code for svgutils.transform
If y is not provided, it is assumed equal to x (according to the W3 ... Element(SVG+"svg", nsmap=NSMAP) self.root.set("version", "1.1") if width: self.width...
Read more >
How to Scale SVG | CSS-Tricks
If you use an <object> , <embed> , or <iframe> to embed your SVG, setting height and width on the <svg> won't change...
Read more >
Scaling Issues
The SVG files produced by svglite do not include width and height ... The scaling straightforward but requires some understanding of the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found