Skip to main content

Viewer for Altair and Vega-Lite visualizations.

Project description

Altair Viewer

Offline chart viewer for Altair visualizations

github actions github actions code style black

This package provides tools for viewing Altair charts without a web connection in arbitrary Python environments. Charts can be displayed either inline in a Jupyter notebook environment, or in a separate browser window for use in any environment.

Altair Viewer Gif

Installation

Altair Viewer can be installed from the Python Package Index with pip:

$ pip install altair_viewer

Usage: General Environments

Altair viewer provides two top-level functions for displaying charts: display() and show(). Their intended use is slightly different:

import altair_viewer
altair_viewer.display(chart)

display(chart) is meant for use in interactive computing environments where a single Python process is used interactively. It will serve a chart viewer at a localhost URL, and any susequent chart created within the session will appear in the same window. The background server will be terminated when the main Python process terminates, so this is not suitable for standalone scripts.

import altair_viewer
altair_viewer.show(chart)

show(chart) is meant for use once at the end of a Python script. It does the same as display(), but automatically opens a browser window, and adds an input prompt to prevent the script (and the server it creates) from terminating.

Usage: IPython & Jupyter

Within Jupyter notebook, IPython terminal, and related environments that support Mimetype-based display, altair viewer can be used by enabling the altair_viewer renderer:

import altair as alt
alt.renderers.enable('altair_viewer')

This will cause charts at the end of a Jupyter notebook cell to be rendered in a separate browser window, as with the display() and show() methods.

If enabled with inline=True, charts will be rendered inline in the notebook:

import altair as alt
alt.renderers.enable('altair_viewer', inline=True)

To display a single inline chart using Altair viewer in an IPython environment without globally enabling the associated renderer, you can use the display method directly:

import altair_viewer
altair_viewer.display(chart, inline=True)

Note that the display based on altair viewer will only function correctly as long as the kernel that created the charts is running, as it depends on the background server started by the kernel. In particular, this means that if you save a notebook and reopen it later, charts will not display until the associated cells are re-run.

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

altair_viewer-0.4.0.tar.gz (841.5 kB view details)

Uploaded Source

Built Distribution

altair_viewer-0.4.0-py3-none-any.whl (844.5 kB view details)

Uploaded Python 3

File details

Details for the file altair_viewer-0.4.0.tar.gz.

File metadata

  • Download URL: altair_viewer-0.4.0.tar.gz
  • Upload date:
  • Size: 841.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for altair_viewer-0.4.0.tar.gz
Algorithm Hash digest
SHA256 f5d33df775cb9094544f15e9b5788224488f506cf546c708980d2d44c2f93534
MD5 fe5febc91ddff5833903a897656e5208
BLAKE2b-256 9e55976c41be000f996978ddd48d304939515ed00a160b669c819cc3b6d068c9

See more details on using hashes here.

File details

Details for the file altair_viewer-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: altair_viewer-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 844.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for altair_viewer-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5da49c52ad9fc56b823cc479b8e5332324d1544b3f7ae4939c25a8585eae5245
MD5 413e041531348a76f94c08a4b35e25e7
BLAKE2b-256 f1e60890752f10ba12cfff4d6a86771e4881d259b735fb6f4de9a34f4a0b0874

See more details on using hashes here.

Supported by

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