![]() If the filename is not given, it is derived from the script name (e.g. Each plot will result in a distinct SVG file. def export_svgs ( obj : UIElement | Document, *, filename : str | None = None, width : int | None = None, height : int | None = None, webdriver : WebDriver | None = None, timeout : int = 5, state : State | None = None ) -> list : ''' Export the SVG-enabled plots within a layout. ''' svgs = get_svg ( obj, width = width, height = height, driver = webdriver, timeout = timeout, state = state ) return _write_collection ( svgs, filename, "svg" ) It is recommended to use the default ``fixed`` sizing mode. warning:: Responsive sizing_modes may generate layouts with unexpected size and aspect ratios. Returns: filenames (list(str)) : the list of filenames where the SVGs files are saved. If None, then the current default implicit state is used. timeout (int) : the maximum amount of time (in seconds) to wait for Bokeh to initialize (default: 5) state (State, optional) : A :class:`State` object. webdriver (selenium.webdriver) : a selenium webdriver instance to use to export the image. height (int) : the desired height of the exported layout obj only if it's a Plot instance. ![]() width (int) : the desired width of the exported layout obj only if it's a Plot instance. str, Path, optional) : filename to save document under (default: None) If None, infer from the filename. ``/foo/myplot.py`` will create ``/foo/myplot.svg``) Args: obj (UIElement object) : a Layout (Row/Column), Plot or Widget object to display filename (PathLike, e.g. def export_svg ( obj : UIElement | Document, *, filename : PathLike | None = None, width : int | None = None, height : int | None = None, webdriver : WebDriver | None = None, timeout : int = 5, state : State | None = None ) -> list : ''' Export a layout as SVG file or a document as a set of SVG files. save ( filename ) return abspath ( expanduser ( filename )) fspath ( filename ) # XXX: Image.save() doesn't fully support PathLike image. height = 0 : raise ValueError ( "unable to save an empty image" ) filename = os. ''' image = get_screenshot_as_png ( obj, width = width, height = height, scale_factor = scale_factor, driver = webdriver, timeout = timeout, state = state ) if filename is None : filename = default_filename ( "png" ) if image. If you would like to access an Image object directly, rather than save a file to disk, use the lower-level :func:`~bokeh.io.export.get_screenshot_as_png` function. ![]() Returns: filename (str) : the filename where the static file is saved. state (State, optional) : A :class:`State` object. timeout (int) : the maximum amount of time (in seconds) to wait for Bokeh to initialize (default: 5) (Added in 1.1.1). scale_factor (float, optional) : A factor to scale the output PNG by, providing a higher resolution while maintaining element relative scales. ``/foo/myplot.py`` will create ``/foo/myplot.png``) Args: obj (UIElement or Document) : a Layout (Row/Column), Plot or Widget object or Document to export. def export_png ( obj : UIElement | Document, *, filename : PathLike | None = None, width : int | None = None, height : int | None = None, scale_factor : float = 1, webdriver : WebDriver | None = None, timeout : int = 5, state : State | None = None ) -> str : ''' Export the ``UIElement`` object or document as a PNG. models.ui import UIElement #- # Globals and constants #- _all_ = ( 'export_png', 'export_svg', 'export_svgs', 'get_layout_html', 'get_screenshot_as_png', 'get_svgs', ) #- # General API #. ![]() util import default_filename if TYPE_CHECKING : from. resources import INLINE, Resources from. getLogger ( _name_ ) #- # Imports #- # Standard library imports import io import os from contextlib import contextmanager from os.path import abspath, expanduser, splitext from tempfile import mkstemp from typing import ( TYPE_CHECKING, Any, Iterator, cast, ) # External imports from PIL import Image if TYPE_CHECKING : from import WebDriver # Bokeh imports from. #- ''' ''' #- # Boilerplate #- from _future_ import annotations import logging # isort:skip log = logging. # The full license is in the file LICENSE.txt, distributed with this software. #- # Copyright (c) 2012 - 2023, Anaconda, Inc., and Bokeh Contributors.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |