Skip to article frontmatterSkip to article content

Rendering

pfund-plot still comes in handy if you just want to use its rendering capabilities. It supports rendering plots in:

  • jupyter notebook/lab
  • marimo notebook
  • browser
  • desktop window

natively pfund-plot only supports inputs created by panel, but there are ways to handle plots from other libraries such as altair and plotly

from pfund_plot.renderer import render

Rendering panel plots in desktop window

import panel as pn

py_code = "import pfund_plot as plt"
editor = pn.widgets.CodeEditor(value=py_code, sizing_mode='stretch_width', language='python', height=300)

# use pfund-plot to render the plot in a desktop window
render(editor, display_mode='desktop')

Rendering plotly plots in browser

import plotly.graph_objects as go

fig = go.Figure(...)

# convert the plotly figure to a panel figure
fig = pn.pane.Plotly(fig)
render(fig, display_mode='browser')

Rendering altair plots in browser

import altair as alt

fig = alt.Chart(...)

# similarly, convert the altair figure to a panel figure
fig = pn.pane.Vega(fig)
render(fig, display_mode='browser')