- ml_research_tools.tex.backend.svg_patch.transform_text_between_dollars(text, transform_func)[source]#
Finds text enclosed between non-escaped dollar signs, applies the given transformation function to that text, and returns the transformed string.
- class ml_research_tools.tex.backend.svg_patch.SvgInkConfig(ignore_font_size=False, ignore_weight=False, ignore_color=False, ignore_alpha=False, ignore_style=False, font_scale=1.0)[source]#
Bases:
object
- Parameters:
- class ml_research_tools.tex.backend.svg_patch.RendererInkSVG(width, height, svgwriter, basename=None, image_dpi=72, *, metadata=None)[source]#
Bases:
RendererSVG
- draw_text(gc, x, y, s, prop, angle, ismath=False, mtext=None)[source]#
Draw a text instance.
Parameters#
- gc.GraphicsContextBase
The graphics context.
- xfloat
The x location of the text in display coords.
- yfloat
The y location of the text baseline in display coords.
- sstr
The text string.
- prop~matplotlib.font_manager.FontProperties
The font properties.
- anglefloat
The rotation angle in degrees anti-clockwise.
- ismathbool or “TeX”
If True, use mathtext parser.
- mtext~matplotlib.text.Text
The original text object to be rendered.
Notes#
Notes for backend implementers:
.RendererBase.draw_text also supports passing “TeX” to the ismath parameter to use TeX rendering, but this is not required for actual rendering backends, and indeed many builtin backends do not support this. Rather, TeX rendering is provided by ~.RendererBase.draw_tex.
- class ml_research_tools.tex.backend.svg_patch.FigureCanvasInkSVG(figure=None)[source]#
Bases:
FigureCanvasSVG
- fixed_dpi = None#
- print_svg(filename, *, bbox_inches_restore=None, metadata=None, **kwargs)[source]#
Parameters#
- filenamestr or path-like or file-like
Output target; if a string, a file will be opened for writing.
- metadatadict[str, Any], optional
Metadata in the SVG file defined as key-value pairs of strings, datetimes, or lists of strings, e.g.,
{'Creator': 'My software', 'Contributor': ['Me', 'My Friend'], 'Title': 'Awesome'}
.The standard keys and their value types are:
str:
'Coverage'
,'Description'
,'Format'
,'Identifier'
,'Language'
,'Relation'
,'Source'
,'Title'
, and'Type'
.str or list of str:
'Contributor'
,'Creator'
,'Keywords'
,'Publisher'
, and'Rights'
.str, date, datetime, or tuple of same:
'Date'
. If a non-str, then it will be formatted as ISO 8601.
Values have been predefined for
'Creator'
,'Date'
,'Format'
, and'Type'
. They can be removed by setting them to None.Information is encoded as Dublin Core Metadata.