[英]how to create compressed scalable vector graphics including metadata from within matplotlib
Is there a way in python to add metadata to the xml tree and export it to svgz at the compression rate achieved by matplotlib.pyplot.savefig(..., format='svgz')
? python中有没有办法将元数据添加到xml树并以matplotlib.pyplot.savefig(..., format='svgz')
实现的压缩率将其导出到svgz?
Maybe you would like to do this也许你想这样做
import io
from matplotlib.figure import Figure
from matplotlib.backends.backend_svg import FigureCanvasSVG
fig = Figure()
# do your fig stuffs
output = io.BytesIO()
FigureCanvasSVG(fig).print_svg(output)
Now, the SGV can be extracted as fol:现在,SGV 可以提取如下:
output.getvalue()
If you are looking for SGVZ (gzip compressed) try:如果您正在寻找 SGVZ(gzip 压缩),请尝试:
FigureCanvasSVG(fig).print_svgz(output)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.