SVGExporter#
- pyqtgraph.exporters.SVGExporter._generateItemSvg(item, nodes=None, root=None, options=None)[source]#
This function is intended to work around some issues with Qt’s SVG generator and SVG in general.
Warning
This function, while documented, is not considered part of the public API. The reason for its documentation is for ease of referencing by
generateSvg()
. There should be no need to call this function explicitly.1. Qt SVG does not implement clipping paths. This is absurd. The solution is to let Qt generate SVG for each item independently, then glue them together manually with clipping. The format Qt generates for all items looks like this:
<g> <g transform="matrix(...)"> one or more of: <path/> or <polyline/> or <text/> </g> <g transform="matrix(...)"> one or more of: <path/> or <polyline/> or <text/> </g> . . . </g>
2. There seems to be wide disagreement over whether path strokes should be scaled anisotropically. Given that both inkscape and illustrator seem to prefer isotropic scaling, we will optimize for those cases.
Note
3. Qt generates paths using non-scaling-stroke from SVG 1.2, but inkscape only supports 1.1.
Both 2 and 3 can be addressed by drawing all items in world coordinates.
- Parameters:
item (
GraphicsItem
) – GraphicsItem to generate SVG ofnodes (
dict
ofstr
, optional) – dictionary keyed on graphics item names, values contains the XML elements, by default Noneroot (
GraphicsItem
, optional) – root GraphicsItem, if none, assigns to item, by default Noneoptions (
dict
ofstr
, optional) – Options to be applied to the generated XML, by default None
- Returns:
tuple where first element is XML element, second element is a list of child GraphicItems XML elements
- Return type: