Is there a difference in performance / ease of use between templates?

I have a dumb question , but I’m pretty lost and I was searching for a discord or chat place to ask this but as far as Templates go…
granted I’m a total noob. on a poor performance laptop.
Is there a ranking for the templates in terms of

  • easiest to use
  • best performance

And I’m really getting lost in the libraries and correlation between them.
Like if all I know is Seaborn and Matplotlib ;
I just want a little bit of interaction and being able to share it with colleagues.
Is my understanding correct that kind of just Holoviews for everything ?

Like if someone had to communicate what to stick with just to get the fundamentals.
The problem I’m having is with building blocks ; like I can follow a tutorial on its own but connecting the dots I get lost.

I find the Panel & HoloViews User Guides to be very helpful. There is a section in the Panel guide on Performance and Debugging which discusses layouts. I use the bokeh backend for the interactivity but there is a section on matplotlib.
As a fellow noob, I feel that many of the examples contain too much magic and are missing some basic fundamentals. For example, how do I get the initial axis bounds of an hv.Scatter plot? (That said, I’m also new to bokeh and the magic may be due to my own naivete.).

1 Like

You know whats confusing about the templates docs is that all the pictures are the same , so im confused why one would choose one template over another.

Also another confusing thing is like how does one refresh the server automatically if i change something in jupyter .

From the templates if i want to have in the side panel another page so it goes to another set of dashboards . How does that happen .

Im 3 days into the documents , and as a noob there is a lot of friction and confusion . I think with the name “panels dashboard” i feel like i also run into a lot of faulty references from google .

Maybe im missing something , ill scout more on discourse here . Hopefully someone can link a couple good panel dashboards in jupter notebooks that help.

I tried awesome panel but cant get it to run at all

1 Like

Hi @zartarr88

Welcome to the community.

Templates

The basics of the templates are very similar. But much more effort has been put into the Fast templates so far. So they much, much better support for example dark mode. I would pick the Fast templates - but I’m biased as I contributed those initially.

Awesome Panel

If you cannot get it working please describe the issue here.

Refresh the server

When you start the Panel server with panel serve name_of_notebook.ipynb --autoreload --show, the Panel server will automatically refresh when you save the notebook.

Another page

If what you want is multiple pages in your app its as simple has having multiple notebook files and then run panel serve name_of_file_1.ipynb name_of_file_2.ipynb --autoreload --show.

Panel name

Yes a name that is easier to Google would probably have been chosen if there had been more focus on search engine optimization when the project started in 2018.

HoloViz for everything

HoloViz is a data visualization framework containing hvPlot, HoloViews, Panel and more. The recommended starting point is hvPlot. Then use HoloViews if you need more advanced plotting and Panel if you want to build more advanced (and live) dashboards.

You should be able to stay in those frameworks for everything. But if you are a Matplotlib/ Seaborn user and want to add just a bit of interactivity to it, Panel is the tool to use.

Getting Started

The Getting Started Guide should be a good place to start. If it is not please help the community by describing the issues or what you need at Issues · holoviz/panel.

Matplotlib Examples

If you just want to add a bit of interactivity to Matplotlib you can learn how to combine Matplotlib with Panel via the Matplotlib Reference Guide.

A basic Matplotlib example would look like.

basic-matplotlib-example

import numpy as np

from matplotlib.figure import Figure

def plot(bins=5):
        np.random.seed(19680801)
        x = 100 + 15 * np.random.randn(437)

        fig = Figure(figsize=(12, 6))
        ax = fig.subplots()
        ax.hist(x, bins, density=True)
        return fig

import panel as pn

pn.extension(sizing_mode="stretch_width", template="fast")
pn.state.template.param.update(site="Panel", title="Basic Matplotlib Example")

pn.Row(
    pn.layout.HSpacer(),
    pn.pane.PNG(
        "https://upload.wikimedia.org/wikipedia/commons/thumb/8/84/Matplotlib_icon.svg/180px-Matplotlib_icon.svg.png",
        sizing_mode="fixed",
    ),
    pn.layout.HSpacer()
).servable(target="sidebar")
bins = pn.widgets.IntSlider(value=20, start=20, end=100, step=20, name="Bins").servable(target="sidebar")
iplot = pn.bind(plot, bins=bins)

pn.panel(iplot, sizing_mode="scale_width", height=500).servable()

You can learn how to style it via the MatplotlibStyle Example.

Seaborn Examples

As seaborn is built on top of Matplotlib, you can indirectly learn how to combine Seaborn with Panel via the Matplotlib Reference Guide.

A basic Seaborn example would look like

seaborn-getting-started

import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib.figure import Figure


def plot(data, plot_type="violinplot"):
        fig = Figure(figsize=(12, 6))
        ax = fig.add_subplot(111)
        
        if plot_type=="violinplot":
            sns.violinplot(x = "year", y = "mass", data = data, ax=ax)
        else:
            sns.stripplot(x = "mass", y = "distance", data = data, ax=ax)
            ax.xaxis.set_major_locator(plt.MaxNLocator(10))
        return fig

import panel as pn

pn.extension(sizing_mode="stretch_width", template="fast")

pn.Row(
    pn.layout.HSpacer(),
    pn.pane.SVG(
        "https://seaborn.pydata.org/_images/logo-tall-lightbg.svg",
        sizing_mode="fixed",
        width=210,
    ),
    pn.layout.HSpacer()
).servable(target="sidebar")
plot_type = pn.widgets.Select(name="Plot Type", value="violinplot", options=["stripplot", "violinplot"]).servable(target="sidebar")

# To avoid reloading data and recalculating the plot for each user we cache the data and plot
planets = pn.state.as_cached("seaborn-planets", sns.load_dataset, name='planets')
def cached_plot(data, plot_type="violinplot"):
    if not plot_type in pn.state.cache:
        pn.state.cache[plot_type]=plot(data, plot_type)
    return pn.state.cache[plot_type]
interactive_plot = pn.bind(cached_plot, data=planets, plot_type=plot_type)

pn.panel(interactive_plot, sizing_mode="scale_width").servable()

pn.state.template.param.update(site="Panel", title="Basic Seaborn Example")

If you want to style seaborn you can get inspired by the below example

seaborn-style

import seaborn as sns
from matplotlib.figure import Figure
import matplotlib.font_manager

NICE_ACCENT_COLORS = [
    "#00A170",  # Mint
    "#DAA520",  # Golden Rod
    "#F08080",  # Light Coral
    "#4099da",  # Summery Sky
    "#2F4F4F",  # Dark Slate Grey
    "#A01346",  # Fast
]

ACCENT = NICE_ACCENT_COLORS[2]

STYLES = [
    "dark",
    "ticks",
    "white",
    "whitegrid",
]
PALETTES = [
    "bright",
    "colorblind",
    "dark",
    "deep",
    "hls",
    "husl",
    "muted",
    "pastel",
    f"dark:{ACCENT}",
    f"light:{ACCENT}",
]
FONTS = sorted(set([f.name for f in matplotlib.font_manager.fontManager.ttflist]))

RC_DARK = {
    "axes.labelcolor": "white",
    "axes.facecolor": "black",
    "figure.facecolor": "black",
    "xtick.color": "white",
    "ytick.color": "white",
}


def plot(style="white", palette="deep", font="sans-serif", theme="default"):
    if theme == "dark":
        rc = RC_DARK
    else:
        rc = {}
    # See https://seaborn.pydata.org/generated/seaborn.set_theme.html#seaborn.set_theme
    sns.set_theme(style=style, palette=palette, font=font, rc=rc)
    fig = Figure(figsize=(12, 6))
    ax = fig.add_subplot(111)

    sns.barplot(x=["A", "B", "C"], y=[1, 3, 2], ax=ax)
    return fig


import panel as pn

pn.extension(sizing_mode="stretch_width", template="fast")


def get_theme():
    return pn.state.session_args.get("theme", [b"default"])[0].decode()


THEME = get_theme()
if THEME == "dark":
    PALETTE = f"light:{ACCENT}"
else:
    PALETTE = f"dark:{ACCENT}"

pn.Row(
    pn.layout.HSpacer(),
    pn.pane.SVG(
        "https://seaborn.pydata.org/_images/logo-tall-lightbg.svg",
        sizing_mode="fixed",
        width=210,
    ),
    pn.layout.HSpacer(),
).servable(target="sidebar")

style = pn.widgets.Select(name="Style", value="white", options=STYLES).servable(target="sidebar")
palette = pn.widgets.Select(name="Palette", value=PALETTE, options=PALETTES).servable(
    target="sidebar"
)
font = pn.widgets.Select(name="Font", value="Verdana", options=FONTS).servable(target="sidebar")

interactive_plot = pn.bind(plot, style=style, palette=palette, font=font, theme=THEME)

pn.panel(interactive_plot, sizing_mode="scale_width").servable()

pn.state.template.param.update(
    site="Panel", title="Basic Seaborn Example", header_background=ACCENT, accent_base_color=ACCENT
)

How to get more specific help

Try to describe the kind of app or dashboard you would like to make. Try describe the plotting frameworks you would like to use. That would make it easier to point to examples that are relevant for you.

4 Likes

Hi @zartarr88 and welcome,

Sorry to hear that you got lost in the documentation. I remember that when I started to use the HoloViz tools I actually found the documentation nice, I felt it was extensively covering the available features and appreciated that. However it is also true that the documentation doesn’t do a very good job at actually guiding people, at gradually helping you to on board with the concepts and how they work together across HoloViz but also how they integrate within the more general PyData ecosystem. Improving the docs is one of our targets, we could use some help though so if you feel the soul of a tech writer or happens to know one who wants to contribute to some open-source projects, we welcome everyone!

As for where to look for information, the websites like panel.holoviz.org are the best places, then comes Discourse, and there are indeed more and more blogs but it’s still parse. Another place where you can get some inspiration is examples.pyviz.org. Following the tutorial at holoviz.org can also be a good idea, you can focus on the sections that are dedicated to Panel.

Regarding your specific questions.

You seem to be focusing on performance. Is it because you’re on a poor performance laptop? Or because you’ve noticed some bad performance trying out the tools? You wouldn’t usually start a new project with optimizing performance in mind, because it’s often hard to predict what are going to be the real bottlenecks. Except of course if what you need is an ultra-performant app, but maybe in that case Panel (or Streamlit or Dash or Voila or …) isn’t the solution, as Python dashboarding libraries tradeoff ease of use for some performance overhead.

Is my understanding correct that kind of just Holoviews for everything ?

I’m sorry this sentence isn’t very clear to me. Yet I’ll try to clarify a few things. HoloViews is a library for visual data exploration. You can use it without having to know anything about Panel, creating plots in a Notebook for your analysis for instance. Conversely Panel is a dashboarding library and you can use it without knowing anything about HoloViews. As HoloViews and Panel are both part of the HoloViz project, and in practice developed by the same people, they integrate pretty well with each other, which allows you to create powerful dashboards with interactive visualizations, interactive not only in the sense that you can for instance zoom in a plot (this is a feature of the underlying plotting libraries, like Bokeh or Plotly), but that actions on a plot such as panning can trigger all sorts of events, e.g. filtering a table to only display the visible points of a plot.

I just want a little bit of interaction and being able to share it with colleagues.

In that short sentence you’re asking a lot actually :slight_smile:

You’ll have to define more precisely what kind of interaction you need for us to help you. And you will have to define how you want to share your app with your colleagues. There are many ways to do the latter, some are easy like sending a notebook around, some are more involved like setting up a server.

From the templates if i want to have in the side panel another page so it goes to another set of dashboards . How does that happen .

So you want to create more than one dashboard, cool! What I can tell you at this stage is that yes it’s possible to create an app with “multiple pages”, awesome-panel.org is an example of such app. There are a few ways to do that, and I’m quite sure there’s been other topics over here on Discourse that have addressed that. We should have more info in the docs on the different ways to achieve that. For now I’d advise you to focus on building your first app.

In general it’s been a little difficult to reply to you as you’ve listed many problems but you haven’t explained what you’re trying to achieve, could you elaborate more on that?

2 Likes

Just fresh post, as I think the length of my previous post adds friction to a real response.

Q1) Is my understanding correct, that the difference between FastGrid and FastList is just that ‘Grid’ makes it so each plot is movable ?
Q2 there is 1 thing I run into where this happens; when you hover over some data:
image

This overlay feature is extremely useful, but in some figures I get ??? ; and I can’t figure out why that happens… any thoughts?

Q3 I was curious however if you have digged into this a bit deeper.

  • If I end up with a 2x2 dashboard page ; and this is just how I am able to communicate best with my team. so say 4 panels or panes or whatever the terminology is… have you put thought into what the optimum pixel width and height for said space would be so that it translates into a powerpoint presentation optimally in a similar 2x2 manner. I am wanting to avoid duplication of work and curious if I can bridge the gap. What I want my coworkers to be able to do is either manually copy paste an image without having to resize or mess with pixels etc. Like maybe a best practice for font sizing etc. I’ve found the defaults in hvplot aren’t working and what an automated process would look like. What would be nice if there was a button I could add where they could print to pdf on the dashboard itself as well.

Q4 2nd thing is something like just showing basic infographic/type stats… for instance you have a Price vs Time holoviews chart ; but maybe it has a tiny panel in the top right that shows 1 week ago price, 1 year ago price… and a small arrow if its up or down from yesterday…

It seems to be because of this .

Hi @zartarr88 ,

With regards to question 3, I can’t help here other than say what I do and it’s probably what your looking to iron out but I don’t quite see how myself. My pipeline if you like is setup to be responsive in nature within dashboard template - this look and feel is setup to look the best for the template and screen(s) it is to be used on. I now try and share the template and let the end user decide if they need to extract but if I have to extract I use the save tool, which will either save single or multiple graphs pending what is in the framework, and use the snipping tool for worst case I often use this when I make the dashboard pane go to full screen then I can just pretty much print screen. Then as my work also makes use of the microsoft system I import into powerpoint. If there was to be a magic button that could give you a nice graph / font size automagically that would be awesome but seems very subjective and would probably be required to have a heap of options to get it just right for your particular use case… I have come to terms if I need to put stuff into presentation then things may need to be tweaked or here’s my analyses part and here’s my presentation part. If I take the output of the png, when I scale to powerpoint size, everything scales, and I can see that all the text gets smaller that makes sense and but it would seem you would want it to go the other way at least sometimes I do but where does it stop…, scale the plot down to fit the new size of powerpoint and scale the text up to be readable at a glance but on the dashboard the text might then be so big the analyses part doesn’t look right and gets in the way. Maybe there is a way out of this subjective use cases might be common ground for many :melting_face: in short I accept that I make something look just right for the plot in the dashboard and getting it out into another format I have to think about and take the time to get right myself

1 Like