Two-dimensional histogram (density plot) with textual output.
Create a textual 2-D density/histogram plot given binned data.
data: Two-dimensional values (e.g. list of lists of floats)color_map: One of the above color maps (Default: 256-color grayscale)render_halfheight: Bool indicating whether to use half-block characters to double the vertical resolution (Default: True)font_mapping: character/glyph mapping based on terminal capabilities (Default: lineart.basic_font)min_data: Data value that should correspond to minimum colormax_data: Data value that should correspond to maximum colorx_axis: Axis object for X axisy_axis: Axis object for Y axisflip_y: Output minimum Y as first line (Default: True)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).
Simple helper function to output/print a plot. Calls as_strings() and outputs each line with the printer function.
printer: Function to use for output. Default: print()Scale up ‘data’ by repeating lines and values within lines.
max_size
max_expansion (default (3,3))
keep_aspect_ratio (default False)
Axis-generation support.
value_range: Tuple/List/util.ValueRange with the Axis limitslabels: dict of coordinate value -> string to print as axis label. If None (default), labels will be autogeneratedlabel_fmt: For autogenerated labels, specifies the number formatting, e.g. ‘’. Default {}border_line: Include a line along the axis in the output. Default Falsevalues_are_edges: True for histogram-like data, where labeled values are typically the edges of the histogram bins. Default Falsefractional_tick_pos: Use various characters to indicate where an axis tick is, rather than just “-“ or “|”. Default FalseBin points into a 2-D histogram, given number of bins, or bin edges
points: Sequence of (X,Y) tuples
bins: int or (int, int) or [float,…] or ([float,…], [float,…])
ranges: Optional (ValueRange, ValueRange)
bin_sizes: float or tuple(float, float)
align: bool (default: True)
drop_outside: bool
axis_args: Extra arguments to pass through to Axis constructorreturns tuple: (Sequence[Sequence[int]], (x-)Axis, (y-)Axis)
Support for smoothing pointwise data for a density map.
Produce a Gaussian (normal) smoothing kernel, given an inverse covariance matrix
Produce a Gaussian (normal) smoothing kernel, given widths in X and Y
Produce a triangular smoothing kernel with given widths
points: Sequence of (X,Y) tuples
kernel: SmoothingFunc
bins: int or (int, int) or [float,…] or ([float,…], [float,…])
ranges: Optional (ValueRange, ValueRange)
align: bool (default: True)
axis_args: Extra arguments to pass through to Axis constructorUtility functions to try to detect terminal/font capabilities
Varieties of terminal/font glyph rendering support
Try to determine the terminal’s color support.
interactive: bool
debug: bool
Returns ColorSupport
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
Some dicts mapping ColorSupport level to Color Maps are provided:
Maps to Truecolor / 256-color Grayscale, or to ASCII-Art
Maps to appropriate TrueColor/256-Color/16-color FADE_IN (Black -> Purple -> Blue -> Green -> Yellow -> Orange -> Red), or ASCII-art.
Maps to appropriate TrueColor/256-Color/16-color REV_RAINBOW (Purple -> Blue -> Green -> Yellow -> Orange -> Red), or ASCII-art.
Also exported as densitty.histplot2d()
Wrapper for binning.histogram2d / plot.Plot to simplify 2-D histogram plotting
points: Sequence of (X,Y) tuples
bins: int or (int, int) or [float,…] or ([float,…], [float,…])
ranges: Optional (ValueRange, ValueRange)
bin_sizes: float or tuple(float, float)
align: bool (default: True)
drop_outside: bool
colors: dict
border_line: Include a line along the axis in the output. Default Truefractional_tick_pos: Use various characters to indicate where an axis tick is, rather than just “-“ or “|”. Default Falsescale: True, False, or int
plotargs
Plot constructor.Also exported as densitty.densityplot2d()
Wrapper for smoothing.smooth2d / plot.Plot to simplify 2-D histogram plotting
points: Sequence of (X,Y) tuples
kernel: SmoothingFunc
bins: int or (int, int) or [float,…] or ([float,…], [float,…])
ranges: Optional (ValueRange, ValueRange)
align: bool (default: True)
colors: dict
border_line: Include a line along the axis in the output. Default Truefractional_tick_pos: Use various characters to indicate where an axis tick is, rather than just “-“ or “|”. Default Falseplotargs: Extra arguments to pass through to plot functionAlso exported as densitty.grid_heatmap()
Create a grid-style heatmap, with user-provided labels for each column and row.
data: Two-dimensional values (e.g. list of lists of floats)x_labels: list of stringsy_labels: list of stringscolors: dict mapping color support level to colormap. (default REV_RAINBOW)max_cell_size: int
plotargs: Extra arguments to pass through to plot functionDetect color support and pick the best color map
Wrapper for plot.Plot that picks colormap from dict
data: Two-dimensional values (e.g. list of lists of floats)colors: dict
plotargs
Plot constructorCharacter translations
ascii_font
basic_font
extended_font
Note: these colors are typically user-configurable in terminal emulators, and can vary dramatically from this picture.
Note: these colors are often user-configurable in terminal emulators, and can vary from this picture.
Note: less variable than 16-color or 256-color, appearance can still depend on the system, gamma correction, etc.
Note: Different fonts can have different “densities” for these characters.
These functions are used to create the above color maps. Using them to create your own is straightforward; see the code for examples.