Here is a list of questions we have either been asked by users or potential pitfalls we hope to help users avoid:
Q: What objects can I use with Panel?
A: The Panel Reference Guide shows examples of all the plotting libraries, data types, image formats, and other objects that can be used in a panel. There is also a Github issue where possible types are discussed.
Q: Does it matter which plotting library I use with Panel?
Q: How do I add support for a library or datatype not yet supported?
A: It depends. If the object already has one of the usual IPython
_repr_X_ rich display methods (where X is png, jpg, svg, or html), then it is very likely to work already. Try it! If it doesn’t have a rich display method, check to see if you can add one as a PR to that project – those representations are very useful for many cases other than Panel, too. Otherwise, adding support is quite easy for anything that can somehow return an image or some HTML. If it can return an image in any way, see the
panel.pane.Matplotlib implementation as a starting point; you just need to be able to call some method or function on the object to return an image, and the rest should be simple.
pane.Bokeh class and the
panel.plotly modules for examples.
Q: How does Panel relate to Bokeh?
A: Panel is built on infrastructure provided by Bokeh, specifically Bokeh’s model base classes, layouts, widgets, and (optionally) its server. But Panel does not require using any of Bokeh’s plotting support. This way you can make use of a solid, well supported low-level toolkit (Bokeh) to build apps and dashboards for your own plots from any supported library.
Q: Why is my object being shown using the wrong type of pane?
A: A global set of precedence values is used to ensure that the richest representation of a given object is chosen when you pass it to a Row or Column. For instance, if
obj is “# Some text”, it be displayed as a
pn.Markdown, all of which can render a Python string like that. By default, something like
pn.Row(obj) will select a Markdown pane for the obj, because Markdown has a higher precendence than the other options. If you want to override the default pane type selected, you can specify the precise Pane type you wish, as in
pn.Row(pane.Str("# Some text")), which also allows you to pass in options like
pn.Row(pane.Str("# Some text", height=300)). If the default Pane type is fine but you still want to be able to pass specific options like width or height in this way, you can invoke the
pn.panel function to create a defauot pane with the supplied arguments, as in
Q: For Matplotlib plots in a notebook, why do I get no plot, two plots, or plots that fail to update?
A: The Matplotlib pyplot interface behaves in a way that is not easily compatible with Panel in a notebook. Normal Python objects like Python literals and containers display when they are returned as a cell’s value, but Matplotlib figures created using pyplot have a textual representation by default but then (depending on the Matplotlib backend and IPython configuration) also display like print statements do, i.e. with a plot as a side effect rather than as a representation of the return value. To force predictable Panel-compatible behavior we therefore recommend using the object-oriented API:
- Create a figure object explicitly using
from matplotlib.figure import Figure
- In versions of matplotlib < 3.1 use
from matplotlib.backends.backend_agg import FigureCanvasto initialize a canvas
- Return the figure in your callback.
As an example creating a simple plot might look like this:
fig = Figure(figsize=(10, 6)) FigureCanvas(fig) # not needed if Matplotlib >= 3.1 ax = fig.subplots() ax.plot([1, 2, 3]) pn.pane.Matplotlib(fig)
When using the pandas plotting API we create the figure and axes in the same way as before but then pass the axis to the plotting call:
df.plot([1, 2, 3], ax=ax) pn.pane.Matplotlib(fig)
Q: How do I debug error messages in a notebook?
A: When displaying a Panel object in a Jupyter notebook, any errors triggered by interacting with the app or dashboard will be logged to the browser’s developer console instead of the usual python standard output on the commandline. How you access the developer console depends on your browser:
- Chrome: Menu -> More tools -> Developer Tools
- Firefox: Menu -> Web developer -> Browser console
- Safari: Menu -> Develop -> Show error console
Q: Does Panel require a live Python process for deployment, or can I export to a static HTML document to email or put on a web server?
.jslink will still be connected, as will widget states collected using
Q: How can I deploy a Panel app for others to use?
A: There are many options available; see the Deployment section of the user manual. The basic idea is if you can log into a machine and launch a web server process, you can use
panel serve there
Q: Is Panel ‘Shiny for Python’?
A: Yes and no. Yes, in the sense that all the bold text on Shiny’s home page (as of 11/2019) is also true of Panel, once you replace “Shiny” with “Panel” and “R” with “Python”:
- “[Panel] is an [Python] package that makes it easy to build interactive web apps straight from [Python]”
- “[Panel] combines the computational power of [Python] with the interactivity of the modern web”
- “[Panel] apps are easy to write. No web development skills are required”
- “Put your [Panel] app on the web by using your own servers or [a] hosting service”
That said, Panel is in no way a clone of Shiny; Panel is a complete solution for browser-based interactivity, whether by adding a single widget to a notebook cell or by building a complex multipage app, designed to support the entire data-science workflow. Panel is also not associated with any particular public hosting provider, unlike Shiny.
Q: Can Panel be used like Powerpoint?
A: Panel works very well with RISE, which lets a Jupyter notebook (including any Panel layouts) be used for a fully interactive full-screen presentation.
Q: What performance limitations does Panel have?
A: Performance of a Panel app is generally limited by the underlying contents of the page, rather than by Panel itself. Panel apps can take a long time to launch initially if the script requires loading a large file, and Panel allows arbitrary computations to be performed on any interactive event (e.g. a mouse click or slider interaction), some of which may be slow to compute. Panel works well with the Numba Python compiler and with the Dask distributed computing library, which should allow you to get all the speed you need if you have sufficient processing power available.
Q: Is support for geographic maps included with Panel?
A: Panel supports displaying and working with almost anything, including geographic maps. Panel is part of the HoloViz suite of tools, which includes the GeoViews package that works seamlessly with Panel to create fully interactive map-based apps with just a few lines of code. Most other Python map tools should also work!
Q: How stable is Panel?
A: Panel is a relatively new project, pre-released in 2018 and first fully released in Spring 2019. But Panel is built on infrastructure from the Bokeh project that has been continuously improved since 2012, and Panel has very rapidly established a stable API and a large and active userbase, making the project already fully stable for production applications. New features are appearing rapidly, but generally without any changes to existing API.
Q: How does Panel fit into the Python ecosystem?
A: Panel can be used in an almost infinite variety of settings, so that’s a very difficult question to answer. But we can tell you how we designed Panel, and how it fits with the other tools we develop or use frequently: HoloViz ecosystem.
Q: Can Panel be used for real-time or streaming display updates?
A: Yes! Panel apps are reactive to events in general, whether those events come from user interactivity or any other source. E.g. it works well with the Streamz library for processing streaming data sources.
Q: Can Panel make multipage applications?
A: Of course! Panels can completely reconfigure themselves as needed, so it is possible to build just about anything you can see in a web page. In practice, one of these approaches can probably do what you want:
- Panel Pipelines provide an easy way to build a workflow where users first start on one page, make selections, then move to subsequent pages. Pipelines can be linear (with one following page each time) or branching (with choices made on one page determining where to go on the next).
- Panel Tabs let you provide users with a selection of different panels to choose from in any order, using one at a time.
- Bokeh/Panel Templates let you create arbitrary HTML/JS/CSS web pages around your panel components, where you can provide any control mechanism you like (though with a lot more effort than pipelines or tabs, unless you can copy an existing template).
- Bokeh embed functions allow you to embed static or server based Panel objects into your existing website.
Q: Which server architecture should I use with Panel?
|Supports Panel apps||Yes||Yes (via jupyter_bokeh)||Yes|
|Supports notebook layout (code cells)||Yes||Yes, optionally||No|
|Allows code editing||Yes||No||No|
|Supports web-page layout||No||Yes||Yes|
|Supports ipywidgets||Yes||Yes||No (as of 10/2019)|
|Can designate each output for display||N/A||No (except with template)||Yes|
|Allows shared state across sessions||No||No||Yes|
Panel works seamlessly with Jupyter notebooks for interactive editing, and it uses Bokeh Server to serve apps by default (aliasing it as
panel serve). Panel can also be used with Voila if you install the separate
jupyter_bokeh library, which lets you incorporate ipywidgets-based tools into the same app as Panel objects. Other server technologies like Streamlit and Dash do not currently provide full support for Panel; they can typically display Panel objects but don’t support the bidirectional communication needed for full Python-backed panel interactivity.
Q: How does Panel relate to other widget/app/dashboard tools?
A: Python has a rich, dynamic, and ever-expanding ecosystem, so any comparison can quickly go out of date. Also, most tools compare to only a small part of what Panel provides, as Panel is designed to support the entire life cycle of working with data: from initial exploration, to adding custom interactivity to make one-off analyses easier, to building a complex dashboard from multiple components, to deploying your polished Python-backed dashboard in a public-facing or on-premises private server, and then iterating by bringing those same components back to the notebook for further exploration and improvement. Other tools support some of the same capabilities, but by focusing on only one part of this life cycle they typically require you to start over when you need to use your work in a different way.
The Comparisons page describes some of these differences in detail, but at a high level:
|Provides widgets and layouts||Yes||Yes||Yes||Yes||Yes||Yes|
|Supports callbacks on plots||Yes||Yes||Yes||No||Yes||Yes|
|Supports incremental plot updates||Yes||Yes||Yes||Yes (in some cases)||Yes||Yes|
|Fully usable in Jupyter||Yes||Yes||Yes, with jupyter_bokeh||No||No, only via iframe||No|
|Supports static HTML export from notebooks (for reports, docs, etc.)||Yes||Not without a special embedding procedure||Yes||No||No||No|
|Supports Matplotlib plots||Yes||Yes||No||Yes||With a separate adapter||No|
|Supports Bokeh plots||Yes||Yes||Yes||Yes||With a separate adapter||No|
|Supports Plotly plots||Yes||Yes||No||Yes||Yes||Yes|
|Supports R ggplot plots||Yes||No||No||No||No||Yes|
|Supports Altair/Vega plots||Yes||Yes||No||Yes||With a separate adapter||Yes|
|Supports Django and Django channels||Yes||No||Yes||No||No||No|
|Allows separating business logic from presentation||Yes||No||No||No||No||No|
|Servers supported||Jupyter, Bokeh, Voila||Jupyter, Voila||Jupyter, Bokeh, Voila||Streamlit||Dash||Shiny server|
Each of these libraries are free, open-source software packages, but all of them can be used with the commercial Anaconda Enterprise (AE5) server product, and some can be used with other commercial servers (Shiny, with Shiny Server, Streamlit, with Streamlit Teams, and Dash, with Dash Enterprise), to provide on-premises authenticated deployment within a private network. Most of the servers (including Jupyter, Bokeh Server, Voila, and Dash) can be also deployed on the public sites mybinder.org or heroku.