MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / RendererSVG

Class RendererSVG

lib/matplotlib/backends/backend_svg.py:302–1314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300
301
302class RendererSVG(RendererBase):
303 def __init__(self, width, height, svgwriter, basename=None, image_dpi=72,
304 *, metadata=None):
305 self.width = width
306 self.height = height
307 self.writer = _XMLWriter(svgwriter)
308 self.image_dpi = image_dpi # actual dpi at which we rasterize stuff
309
310 if basename is None:
311 basename = getattr(svgwriter, "name", "")
312 if not isinstance(basename, str):
313 basename = ""
314 self.basename = basename
315
316 self._groupd = {}
317 self._image_counter = itertools.count()
318 self._clip_path_ids = {}
319 self._clipd = {}
320 self._markers = {}
321 self._path_collection_id = 0
322 self._hatchd = {}
323 self._has_gouraud = False
324 self._n_gradients = 0
325
326 super().__init__()
327 self._glyph_map = dict()
328 str_height = _short_float_fmt(height)
329 str_width = _short_float_fmt(width)
330 svgwriter.write(svgProlog)
331 self._start_id = self.writer.start(
332 'svg',
333 width=f'{str_width}pt',
334 height=f'{str_height}pt',
335 viewBox=f'0 0 {str_width} {str_height}',
336 xmlns="http://www.w3.org/2000/svg",
337 version="1.1",
338 id=mpl.rcParams['svg.id'],
339 attrib={'xmlns:xlink': "http://www.w3.org/1999/xlink"})
340 self._write_metadata(metadata)
341 self._write_default_style()
342
343 def _get_clippath_id(self, clippath):
344 """
345 Returns a stable and unique identifier for the *clippath* argument
346 object within the current rendering context.
347
348 This allows plots that include custom clip paths to produce identical
349 SVG output on each render, provided that the :rc:`svg.hashsalt` config
350 setting and the ``SOURCE_DATE_EPOCH`` build-time environment variable
351 are set to fixed values.
352 """
353 if clippath not in self._clip_path_ids:
354 self._clip_path_ids[clippath] = len(self._clip_path_ids)
355 return self._clip_path_ids[clippath]
356
357 def finalize(self):
358 self._write_clips()
359 self._write_hatches()

Callers 1

print_svgMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…