-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compose
creates empty figure
#78
Comments
compose
saves empty figurecompose
creates empty figure
Okey, I just found that the created figure is in fact not empty, but the panel is just gigantically huge. The following works for me: #!/usr/bin/env python
#coding=utf-8
from svgutils.compose import *
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots(1, figsize=(4,4))
ax.plot(np.sin(np.linspace(0,2.*np.pi)), np.cos(np.linspace(0,2.*np.pi)))
fig.savefig('cover.svg')
Figure("16cm", "6.5cm",
Panel(SVG('cover.svg')).scale(0.02), # <---- difference to above
).save("composed.svg") Still, I am wondering why the figure ends up so large. With |
I can't comment on the scaling, and the size inconsistency, but since I also struggled for a while with this library and found some solution, I share it here: After all, figure sizes do not really matter for vector graphics. Instead of using units, guessing scalings and figure sizes, I would recommend the following code for a figure with 2.5 times the width and 1.1 times the height of svg = SVG('cover.svg', fix_mpl=True)
Figure(2.5*svg.width, 1.1*svg.height, Panel(svg)).save('composed.svg') |
OS: Ubuntu 20.04 LTS
python: 3.8
Setup
I installed within a conda environment with:
Problem
cover.svg
looks correct, butcomposed.svg
is a blank canvas. Interestingly, it works when usingsvgutils.transform
Quick fix
Downgrading to
v0.3.1
works:Is there anything I am doing obviously wrong or is this a bug?
The text was updated successfully, but these errors were encountered: