Skip to content

Commit

Permalink
Fixes #179. Match any "scale(w h)" and replace with scale parameter f…
Browse files Browse the repository at this point in the history
…or both.

Version to 1.3.5 quick fix
  • Loading branch information
parrt committed Mar 10, 2022
1 parent 07e1d64 commit e2cb111
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion dtreeviz/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import xml.etree.cElementTree as ET
import pandas as pd
from numbers import Number
Expand Down Expand Up @@ -109,7 +110,9 @@ def scale_SVG(svg:str, scale:float) -> str:
ns = {"svg": "http://www.w3.org/2000/svg"}
graph = root.find(".//svg:g", ns) # get first node, which is graph
transform = graph.attrib['transform']
transform = transform.replace('scale(1 1)', f'scale({scale} {scale})')
pattern = re.compile(f"scale\([0-9.]+\ [0-9.]+\)")
scale_str = pattern.search(transform).group()
transform = transform.replace(scale_str, f'scale({scale} {scale})')
graph.set("transform", transform)

ET.register_namespace('', "http://www.w3.org/2000/svg")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name='dtreeviz',
version='1.3.4',
version='1.3.5',
url='https://github.com/parrt/dtreeviz',
license='MIT',
packages=find_packages(),
Expand Down

0 comments on commit e2cb111

Please sign in to comment.