Skip to main content

Aplanat

Aplanat provides a wrappers (templates) around the bokeh library to simplify the plotting of common plots, with a particular focus on producing plots in Juypyter notebook environments.

Installation

Aplanat is easily installed in the standard python tradition:

git clone --recursive https://github.com/epi2me-labs/aplanat.git
cd aplanat
pip install -r requirements.txt
python setup.py install

or via pip:

pip install aplanat.

Usage

Aplanat does not try to be everything to everyone; this is both the power and downfall of a number of plotting libraries. Being overly generic leads to confusing documentation and boilerplate code. As much as the developers love the declarative nature of ggplot in R, aplanat eschews this approach in search of something more transparent --- aplanat does not try to be too clever with your data. Having said that, the layouts module does provide templates to create facet grids directly from a dataframe.

Rather aplanat attempts to make constructing common plots as simple as possible by translating directly a users inputs into displayed data. Most plotting functions are of the form:

plot = plot_function(
    [series_1_x, series_2_x, ...], [series_1_y, series_2_y, ...],
    name=[series_1_name, series_2_name, ...],
    colors=[series_1_color, series_1_color, ...])

Here are some examples, plotting a kernel density estimate (a simple line plot having computed the transform of the data):

import aplanat
from aplanat import lines, util
data = [....]  # a list or numpy array
x_grid, pdf = util.kernel_density_estimate(data)
plot = lines.line([x_grid], [pdf])
aplanat.show(plot)  # to show the plot in a notebook

To add axis and plot titles:

plot = lines.line(...,
   title='Chart title', x_axis_label='x-axis', y_axis_label='y-axis')

To plot multiple series just extend the lists given to the arguments (this time using points):

from aplanat import points
x0, y0 = [...], [...]
x1, y1 = [...], [...]
plot = points.points([x0, x1], [y0, y1])

Plotting a histogram:

from aplanat import hist
data = [...]   # a list or numpy array
plot = hist.histogram([data], bins=400)

A simple bar plot illustrating counts of groups:

groups = [...]
counts = [...]
plot = bars.simple_bar(groups, counts)

A set of boxplots illustrating how the distribution of variable changes (y-axis) with a second grouping variable (the x-axis):

from aplanat import bars
values = [...] 
groups = [...]  # as long as `values`, indicating the group for each value
plot = bars.boxplot_series(groups, values)

Plot a heat map using a hexagonal binning (as seems to be popular these days):

from aplanat import spatial
x_values = [...]
y_values = [...]
plot = spatial.hexmap(x_values, y_values)

To show multiple plots, use aplanat.grid rather than aplanat.show:

plots = [hist.histogram(x) for x in (...)]
aplanat.grid(plots, ncol=3)

The plots will be shown filling a grid row-wise.

ggplot-like facet_grid

All the above examples show how all the fundamental plotting functions transparently turn vector inputs into plotting variables. To provide a higher-level interface the layouts module provides the ability to create more advanced (multi-) plots. For example a common plot is to create layout a base plot type with data segregated by two facets in a grid. The facet_grid function will accept a pandas dataframe and perform this operation.

from aplanat.layouts import facet_grid
transform= lambda z: z
plot = facet_grid(
    data_frame,
    {'x':'x_variable', 'y':'y_variable', 'col':'colour_variable'},
    lines.line,  # the plot type
    xlim=(0, None), ylim=(0, None),
    transform=(transform, transform),
    facet=('X facet', 'Y facet'),
    height=300, width=300,
    x_facet_heading='X Facetlabel',
    y_facet_heading='Y Facet label',
    x_axis_label='x-axis plot label',
    y_axis_label='y-axis plot label')

The transform callback functions can be used to transform the x and y data for each subplot after it has been selected, allowing arbitrary manipulation.

Metadata

Release files for aplanat 0.6.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aplanat 0.6.20
File Size Uploaded
aplanat-0.6.20.tar.gz 297.9 kB Details

Release files / aplanat-0.6.20.tar.gz

Download URL aplanat-0.6.20.tar.gz
Size 297.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6f56b2671e665a806e9b8877d03fef5a8c8b0850c63ddc2321e72f4e02140084
BLAKE2b-256 checksum
How to use checksums
8db2e79fc8f324dfbe449bda69cd9140635853631c5fe8d205e042d086adabc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.6.20 This release

1 release file

0.6.18

1 release file

0.6.17

1 release file

0.6.16

1 release file

0.6.15

1 release file

0.6.14

1 release file

0.6.13

1 release file

0.6.12

1 release file

0.6.11

1 release file

0.6.10

1 release file

0.6.9

1 release file

0.6.8

1 release file

0.6.6

1 release file

0.6.5

1 release file

0.6.4

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.7

1 release file

0.5.6

1 release file

0.5.5

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.12

1 release file

0.3.11

1 release file

0.3.10

1 release file

0.3.9

1 release file

0.3.8

1 release file

0.3.7

1 release file

0.3.6

1 release file

0.3.5

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.9

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page