:orphan: :py:mod:`cowpatch.svg_utils` ============================ .. py:module:: cowpatch.svg_utils Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: cowpatch.svg_utils.gg_to_svg cowpatch.svg_utils.mpt_to_svg .. py:function:: gg_to_svg(gg, width, height, dpi, limitsize=True, eps=0.01, maxIter=20, min_size_px=10) Convert plotnine ggplot figure to svg and return it (with close to perfect sizing). :param gg: object to save as a png image :type gg: plotnine.ggplot.ggplot :param width: width in inches to be passed to the plotnine's ggplot.save function :type width: float :param height: height in inches to be passed to the plotnine's ggplot.save function :type height: float :param dpi: dots per inch, to be passed to the plotnine's ggplot.save function :type dpi: int :param limitsize: logic if plotnine's ggplot.save function should check if the requested width and height in inches are greater than 50 (assumes the user accidentally entered in these values w.r.t. pixels) :type limitsize: boolean :param eps: maximum allowed difference between height and width output versus the desired output :type eps: float :param maxIter: maximum number of steps that can be used to the difference between desired and output height and width within minimum distance :type maxIter: int :param min_size_px: early stopping rule if converging height or width has a pixel size smaller than or equal to this value (assumes process will not converge) :type min_size_px: int :returns: (aka an svg representation) :rtype: svgutils.tranform representation of the ggplot object .. rubric:: Notes Code idea motified by the stackoverflow question here, https://stackoverflow.com/questions/8598673/how-to-save-a-pylab-figure-into-in-memory-file-which-can-be-read-into-pil-image/8598881 and truly influenced by svgutils.transform.from_mpl function. .. py:function:: mpt_to_svg(gg, width, height, dpi)