holoviews.plotting.renderer module#
Public API for all plotting renderers supported by HoloViews, regardless of plotting package or backend.
- class holoviews.plotting.renderer.Renderer(*, backend, center, css, dpi, fig, fps, holomap, mode, post_render_hooks, size, widget_location, widget_mode, info_fn, key_fn, name)[source]#
Bases:
Exporter
The job of a Renderer is to turn the plotting state held within Plot classes into concrete, visual output in the form of the PNG, SVG, MP4 or WebM formats (among others). Note that a Renderer is a type of Exporter and must therefore follow the Exporter interface.
The Renderer needs to be able to use the .state property of the appropriate Plot classes associated with that renderer in order to generate output. The process of ‘drawing’ is execute by the Plots and the Renderer turns the final plotting state into output.
Parameter Definitions
key_fn = Callable(allow_None=True, constant=True, label='Key fn')
Renderers do not support the saving of object key metadata
info_fn = Callable(allow_None=True, constant=True, label='Info fn')
Renderers do not support the saving of object info metadata
center = Boolean(default=True, label='Center')
Whether to center the plot
backend = String(default='', label='Backend')
The full, lowercase name of the rendering backend or third part plotting package used e.g. ‘matplotlib’ or ‘cairo’.
dpi = Integer(allow_None=True, inclusive_bounds=(True, True), label='Dpi')
The render resolution in dpi (dots per inch)
fig = Selector(default='auto', label='Fig', names={}, objects=['auto'])
Output render format for static figures. If None, no figure rendering will occur.
fps = Number(default=20, inclusive_bounds=(True, True), label='Fps')
Rendered fps (frames per second) for animated formats.
holomap = Selector(default='auto', label='Holomap', names={}, objects=['scrubber', 'widgets', None, 'auto'])
Output render multi-frame (typically animated) format. If None, no multi-frame rendering will occur.
mode = Selector(default='default', label='Mode', names={}, objects=['default', 'server'])
Whether to render the object in regular or server mode. In server mode a bokeh Document will be returned which can be served as a bokeh server app. By default renders all output is rendered to HTML.
size = Integer(default=100, inclusive_bounds=(True, True), label='Size')
The rendered size as a percentage size
widget_location = Selector(allow_None=True, label='Widget location', names={}, objects=['left', 'bottom', 'right', 'top', 'top_left', 'top_right', 'bottom_left', 'bottom_right', 'left_top', 'left_bottom', 'right_top', 'right_bottom'])
The position of the widgets relative to the plot.
widget_mode = Selector(default='embed', label='Widget mode', names={}, objects=['embed', 'live'])
The widget mode determining whether frames are embedded or generated ‘live’ when interacting with the widget.
css = Dict(class_=<class 'dict'>, default={}, label='Css')
Dictionary of CSS attributes and values to apply to HTML output.
post_render_hooks = Dict(class_=<class 'dict'>, default={'svg': [], 'png': []}, label='Post render hooks')
Optional dictionary of hooks that are applied to the rendered data (according to the output format) before it is returned. Each hook is passed the rendered data and the object that is being rendered. These hooks allow post-processing of rendered data before output is saved to file or displayed.
- app(plot, show=False, new_window=False, websocket_origin=None, port=0)[source]#
Creates a bokeh app from a HoloViews object or plot. By default simply attaches the plot to bokeh’s curdoc and returns the Document, if show option is supplied creates an Application instance and displays it either in a browser window or inline if notebook extension has been loaded. Using the new_window option the app may be displayed in a new browser tab once the notebook extension has been loaded. A websocket origin is required when launching from an existing tornado server (such as the notebook) and it is not on the default port (‘localhost:8888’).
- components(obj, fmt=None, comm=True, **kwargs)[source]#
Returns data and metadata dictionaries containing HTML and JS components to include render in app, notebook, or standalone document.
- export_widgets(obj, filename, fmt=None, template=None, json=False, json_path='', **kwargs)[source]#
Render and export object as a widget to a static HTML file. Allows supplying a custom template formatting string with fields to interpolate ‘js’, ‘css’ and the main ‘html’ containing the widget. Also provides options to export widget data to a json file in the supplied json_path (defaults to current path).
- get_plot(obj, doc=None, renderer=None, comm=None, **kwargs)[source]#
Given a HoloViews Viewable return a corresponding plot instance.
- get_plot_state(obj, renderer=None, **kwargs)[source]#
Given a HoloViews Viewable return a corresponding plot state.
- get_size(plot)[source]#
Return the display size associated with a plot before rendering to any particular format. Used to generate appropriate HTML display.
Returns a tuple of (width, height) in pixels.
- html(obj, fmt=None, css=None, resources='CDN', **kwargs)[source]#
Renders plot or data structure and wraps the output in HTML. The comm argument defines whether the HTML output includes code to initialize a Comm, if the plot supplies one.
- classmethod load_nb(inline=False, reloading=False, enable_mathjax=False)[source]#
Loads any resources required for display of plots in the Jupyter notebook
- classmethod plot_options(obj, percent_size)[source]#
Given an object and a percentage size (as supplied by the %output magic) return all the appropriate plot options that would be used to instantiate a plot class for that element.
Default plot sizes at the plotting class level should be taken into account.
- classmethod plotting_class(obj)[source]#
Given an object or Element class, return the suitable plotting class needed to render it with the current renderer.
- save(obj, basename, fmt='auto', key=None, info=None, options=None, resources='inline', title=None, **kwargs)[source]#
Save a HoloViews object to file, either using an explicitly supplied format or to the appropriate default.
- server_doc(obj, doc=None)[source]#
Get a bokeh Document with the plot attached. May supply an existing doc, otherwise bokeh.io.curdoc() is used to attach the plot to the global document instance.
- classmethod state()[source]#
Context manager to handle global state for a backend, allowing Plot classes to temporarily override that state.