densitty

densitty package

densitty.plot

Two-dimensional histogram (density plot) with textual output.

class densitty.plot.Plot(data, color_map, render_halfheight, font_mapping, min_data, max_data, x_axis, y_axis, flip_y)

Create a textual 2-D density/histogram plot given binned data.

as_strings()

Scale the data to 0..1 range and feed it through the appropriate output function to produce the plot. Returns a list of strings (one per line).

show(printer)

Simple helper function to output/print a plot. Calls as_strings() and outputs each line with the printer function.

upscale(max_size, max_expansion, keep_aspect_ratio)

Scale up ‘data’ by repeating lines and values within lines.

densitty.axis

Axis-generation support.

class densitty.axis.Axis(value_range, labels, label_fmt, border_line, values_are_edges, fractional_tick_pos)

densitty.binning

densitty.binning.histogram2d(points, bins, ranges, align, drop_outside, **axis_args)

Bin points into a 2-D histogram, given number of bins, or bin edges

returns tuple: (Sequence[Sequence[int]], (x-)Axis, (y-)Axis)

densitty.smoothing

Support for smoothing pointwise data for a density map.

densitty.smoothing.gaussian_with_inv_cov(inv_cov)

Produce a Gaussian (normal) smoothing kernel, given an inverse covariance matrix

densitty.smoothing.gaussian_with_sigmas(sigma_x, sigma_y)

Produce a Gaussian (normal) smoothing kernel, given widths in X and Y

densitty.smoothing.triangle(width_x, width_y)

Produce a triangular smoothing kernel with given widths

densitty.smoothing.smooth2d(points, kernel, bins, ranges, align, **axis_args)

densitty.detect module

Utility functions to try to detect terminal/font capabilities

Enum densitty.detect.ColorSupport

Flag densitty.detect.GlyphSupport

Varieties of terminal/font glyph rendering support

densitty.detect.color_support(interactive, debug)

Try to determine the terminal’s color support.

Returns ColorSupport

densitty.detect.combining_support(debug)

Detect support for combining unicode characters by seeing how far cursor advances when we output one. See ucs-detect / blessed projects for more full-featured detection

Colormap Dictionaries

Some dicts mapping ColorSupport level to Color Maps are provided:

detect.GRAYSCALE

Maps to Truecolor / 256-color Grayscale, or to ASCII-Art

detect.FADE_IN

Maps to appropriate TrueColor/256-Color/16-color FADE_IN (Black -> Purple -> Blue -> Green -> Yellow -> Orange -> Red), or ASCII-art.

detect.REV_RAINBOW

Maps to appropriate TrueColor/256-Color/16-color REV_RAINBOW (Purple -> Blue -> Green -> Yellow -> Orange -> Red), or ASCII-art.

densitty.detect.histplot2d(points, bins, ranges, align, drop_outside, colors, border_line, fractional_tick_pos, scale, **plotargs)

Also exported as densitty.histplot2d()

Wrapper for binning.histogram2d / plot.Plot to simplify 2-D histogram plotting

densitty.detect.densityplot2d(points, kernel, bins, ranges, align, **axis_args)

Also exported as densitty.densityplot2d()

Wrapper for smoothing.smooth2d / plot.Plot to simplify 2-D histogram plotting

densitty.detect.grid_heatmap(data, x_labels, y_labels, colors, max_cell_size, **plotargs)

Also exported as densitty.grid_heatmap()

Create a grid-style heatmap, with user-provided labels for each column and row.

densitty.detect.pick_colormap(maps)

Detect color support and pick the best color map

densitty.detect.plot(data, colors, **plotargs)

Wrapper for plot.Plot that picks colormap from dict

densitty.lineart module

Character translations

Color Maps

16-Color

16-Color Colormaps Note: these colors are typically user-configurable in terminal emulators, and can vary dramatically from this picture.

256-Color

256-Color Colormaps Note: these colors are often user-configurable in terminal emulators, and can vary from this picture.

24-bit / RGB / Truecolor

RGB Colormaps Note: less variable than 16-color or 256-color, appearance can still depend on the system, gamma correction, etc.

ASCII-Art

ASCII-Art scales Note: Different fonts can have different “densities” for these characters.

Custom color maps

These functions are used to create the above color maps. Using them to create your own is straightforward; see the code for examples.

densitty.ansi.colormap_16(colors)

densitty.ansi.colormap_256(colors)

densitty.ascii_art.color_map(values)

densitty.truecolor.colormap_24b(color_points, num_output_colors=256, interp_in_rgb=False)