class histogrammar.primitives.centrallybin.CentrallyBin(bins, quantity, value=<Count 0.0>, nanflow=<Count 0.0>)[source]

Bases: histogrammar.defs.Factory, histogrammar.defs.Container

Split a quantity into bins defined by irregularly spaced bin centers, with exactly one sub-aggregator filled per datum (the closest one).

Unlike irregular bins defined by explicit ranges, irregular bins defined by bin centers are guaranteed to fully partition the space with no gaps and no overlaps. It could be viewed as cluster scoring in one dimension.


Add two containers of the same type. The originals are unaffected.

__init__(bins, quantity, value=<Count 0.0>, nanflow=<Count 0.0>)

Create a CentrallyBin that is capable of being filled and added.

  • centers (list of float) – the centers of all bins
  • quantity (function returning float) – computes the quantity of interest from the data.
  • value (Container) – generates sub-aggregators to put in each bin.
  • nanflow (Container) – a sub-aggregator to use for data whose quantity is NaN.
Other Parameters:
  • entries (float) – the number of entries, initially 0.0.
  • bins (list of float, Container pairs) – the bin centers and sub-aggregators in each bin.

Return the exact center of the bin that x belongs to.


Iterable over the centers of each bin.


Set of centers of each bin.


List of sub-aggregators, to make it possible to walk the tree.


Copy this container, making a clone with no reference to the original.

static ed(entries, bins, nanflow)

Create a CentrallyBin that is only capable of being added.

  • entries (float) – the number of entries.
  • bins (list of float, Container pairs) – the list of bin centers and their accumulated data.
  • nanflow (Container) – the filled nanflow bin.

Reference to the container’s factory for runtime reflection.

fill(datum, weight=1.0)

Increment the aggregator by providing one datum to the fill rule with a given weight.

Usually all containers in a collection of histograms take the same input data by passing it recursively through the tree. Quantities to plot are specified by the individual container’s lambda functions.

The container is changed in-place.


User’s entry point for reconstructing a container from JSON text.

static fromJsonFragment(json, nameFromParent)

staticmethod(function) -> method

Convert a function to be a static method.

A static method does not receive an implicit first argument. To declare a static method, use this idiom:

class C: def f(arg1, arg2, ...): ... f = staticmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class.

Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see the classmethod builtin.


Return a plain histogram by converting all sub-aggregator values into Counts.


Find the closest index to x.

static ing(bins, quantity, value=<Count 0.0>, nanflow=<Count 0.0>)

Synonym for __init__.


Name of the concrete Factory as a string; used to label the container type in JSON.


Return true iff x is in the nanflow region (equal to NaN).


Find the lower and upper neighbors of a bin (given by exact bin center).

plot(httpServer=None, **parameters)

Generate a VEGA visualization and serve it via HTTP.


Get the low and high edge of a bin (given by exact bin center).


Add a new Factory to the registry, introducing a new container type on the fly. General users usually wouldn’t do this, but they could. This method is used internally to define the standard container types.


Explicitly invoke histogrammar.specialized.addImplicitMethods on this object, usually right after construction (in each of the methods that construct: __init__, ed, ing, fromJsonFragment, etc).

Objects used as default parameter arguments are created too early for this to be possible, since they are created before the histogrammar.specialized module can be defined. These objects wouldn’t satisfy any of addImplicitMethod‘s checks anyway.


Return a copy of this container as though it was created by the ed function or from JSON (the “immutable form” in languages that support it, not Python).


Convert this container to dicts and lists representing JSON (dropping its fill method).

Note that the dicts and lists can be turned into a string with json.dumps.


Used internally to convert the container to JSON without its "type" header.


Return the aggregator at the center of the bin that x belongs to.


Iterable over the containers associated with each bin.


Create an empty container with the same parameters as this one. The original is unaffected.