Reputation: 58721
When using a matplotlib to draw something without axes, savefig()
isn't truly "tight":
import matplotlib.pyplot as plt
circ = plt.Circle((0, 0), 1.0)
plt.gca().add_artist(circ)
plt.gca().set_aspect("equal")
plt.axis("off")
# plt.show()
plt.savefig("out.svg", bbox_inches="tight")
That's because the SVG contains the hidden "background patch"
<g id="patch_1">
<path d="M 0 280.512
L 280.512 280.512
L 280.512 0
L 0 0
z
" style="fill:none;"/>
</g>
How to remove it?
Upvotes: 0
Views: 968
Reputation: 1501
pad_inches
option!
plt.savefig("out.svg", bbox_inches="tight", pad_inches=0)
Upvotes: 1