Skip to main content

PyXLL extension for Holoviz charts and panels

Project description

PyXLL Holoviz Extension

Extension package for the Python Excel add-in PyXLL to add support for Holoviz charts and panels.

This package enables displaying HoloViews, hvPlot, and panel objects in Excel via the PyXLL function pyxll.plot.

Requirements

  • PyXLL >= 5.9.0

Installation

To install, run the following in the same Python environment that the PyXLL add-in is configured to use:

pip install pyxll-holoviz

For installing the Excel add-in PyXLL see the PyXLL user guide.

Examples

The following is a simple example taken from the Holoviz hvplot examples.

It uses hvplot to create a scatter plot figure, and then uses pyxll.plot to display that figure in Excel using PyXLL.

import pyxll
from bokeh.sampledata.penguins import data as df
import hvplot.pandas

@pyxll.xl_func
def test_plot():
    # Create the holoviews figure using hvplot
    figure = df.hvplot.scatter(x='bill_length_mm',
                               y='bill_depth_mm',
                               by='species',
                               responsive=True)

    # Show the figure in Excel
    pyxll.plot(figure)

When this function is called from Excel as a worksheet function, the figure is displayed as an interactive chart in Excel. The kwarg reponsive=True is used so that the figure scales automatically if resized in Excel.

This next example shows how to display a panel in Excel and is taken from the panel basic tutorial.

import pyxll
import panel as pn

@pyxll.xl_func
def test_panel():
    # Create a holoviz panel object
    panel = pn.panel("Hello World")

    # Show the panel in Excel
    pyxll.plot(panel)

When this function is called from Excel as a worksheet function, the panel is displayed as an interactive widget in Excel below the cell where the function was called.

Extras

As well as supporting displaying Holoviz objects via pyxll.plot this package also adds a right click context menu hvPlot Explorer and a new hvplot UDF (worksheet function).

hvPlot Explorer

To use the hvPlot explorer, select a tabular range of data in Excel including the column headers. Then right click to bring up the right click context menu and select hvPlot Explorer.

This will add the Holoviz explorer panel to the worksheet as an interactive control.

hvplot UDF

The worksheet function hvplot plots a pandas DataFrame using hvplot.

Parameters are passed in as a dictionary of keyword arguemnts (kwargs), and additionally as pairs of (key, value).

kwargs can be passed as the second argument as an array, or as additional arguments with the key as one argument followed by the value as the next argument. This is is to allow for passing values are are arrays that can be passed as part of the first kwargs array.

For example, to call the equivalent of the Python code:

df.hvplot(kind='scatter', x='index', y=['value1', 'value2'])

The Excel formula would be the following, where the input DataFrame is in cell A1:

=hvplot(A1,
        {"kind", "scatter"; "x", "index"},
        "y", {"value1", "value2"})

Config

The custom context menu (ribbon) component of this extension can be diabled by adding the following to your pyxll.cfg config file:

[HOLOVIZ]
disable_ribbon = 1

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyxll_holoviz-1.0.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyxll_holoviz-1.0.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file pyxll_holoviz-1.0.0.tar.gz.

File metadata

  • Download URL: pyxll_holoviz-1.0.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for pyxll_holoviz-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c3ce2923bb72bee4c997d212d071b68591671a9e72b547a621399ff45d51fba5
MD5 7e867b35343f22c54386d89b0bc2a726
BLAKE2b-256 5bbae4846ce7782669490e53042026d0bf5676569ee821712de020daa99f3eed

See more details on using hashes here.

File details

Details for the file pyxll_holoviz-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyxll_holoviz-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for pyxll_holoviz-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b65bed8b55f48d7db84b10efdaa127a011faa6a2d69d67633d285876122ae59
MD5 7b9ce795ad6868d0eae1db1e7a9b37dd
BLAKE2b-256 bad14fb2415e4a5606633bf9e22e1bf9ed352ac9b3cf27e2f53c6a2242d54344

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page