Skip to content

graphical.bar

Bar

Bar(
    data,
    value_range,
    *,
    length=None,
    width=None,
    marks=None,
    color=None,
    bgcolor=None,
    invert_negative=None,
    orientation="horizontal",
    origin=None,
    force_origin=None,
    prefer_bg=None,
)

Bar graph.

Parameters:

Name Type Description Default

data

float

The value.

required

value_range

Tuple[float, float]

Lower and upper boundary.

required

length

int

The length of the graph. Defaults to 100.

None

width

int

The width of the bars. Defaults to 1.

None

marks

Union[BarMark, Mark]]

Marks used for the bar. Defaults to "block".

None

color

Union[Color, str]

Color of the bar. Defaults to "default".

None

bgcolor

Union[Color, str]

Background color. Defaults to "default".

None

invert_negative

Literal[reverse, swap]

Use positive marks and invert cell colors for negative number. If None or not supported by marks, the cell is not inverted.

None

orientation

Orientation

(Literal["horizontal", "vertical"], optional): The orientation of the bar. Defaults to "horizontal".

'horizontal'

origin

float

Origin point. Defaults to 0.0.

None

force_origin

bool

Force origin to half cell grid. Defaults to False.

None

prefer_bg

OptimizationStrategy

Replace block characters with background, either "never", for "full" blocks only, or for all. Defaults to "full".

None

segments

segments(length=None)

Returns rendered bar segments.

Parameters:

Name Type Description Default

length

Optional[int]

Override bar graph length.

None

Yields: Segment: Next segment of rendered bar.

Range

Range(
    data,
    value_range,
    *,
    length=None,
    width=None,
    marks=None,
    color=None,
    bgcolor=None,
    invert_negative=None,
    orientation="horizontal",
)

Bases: Bar

Bar with an offset.

Parameters:

Name Type Description Default

data

Tuple[float, float]

Start and end point of range.

required

value_range

Tuple[float, float]

Lower and upper boundary.

required

length

int

The length of the graph. Defaults to 100.

None

width

int

The width of the bars. Defaults to 1.

None

marks

Union[BarMark, Mark]]

Marks used for the bar. Defaults to "block".

None

color

Union[Color, str]

Color of the bar. Defaults to "default".

None

bgcolor

Union[Color, str]

Background color. Defaults to "default".

None

invert_negative

Literal[reverse, swap]

Use positive marks and invert cell colors for negative number. If None or not supported by marks, the cell is not inverted.

None

orientation

Orientation

(Literal["horizontal", "vertical"], optional): The orientation of the bar. Defaults to "horizontal".

'horizontal'

RangeStack

RangeStack(
    data,
    value_range,
    *,
    length=None,
    width=None,
    marks=None,
    colors=["red", "green", "blue", "yellow"],
    bgcolor=None,
    invert_negative=None,
    orientation="horizontal",
)

Bases: Stack

Stack with an offset.

Parameters:

Name Type Description Default

data

Sequence[float]

The values in order of stacking. The first value is the stack offset.

required

value_range

Tuple[float, float]

Lower and upper boundary. Defaults to range of data.

required

length

int

The length of the graph. Defaults to 100.

None

width

int

The width of the bars. Defaults to 1.

None

marks

Union[BarMark, Mark]]

Marks used for the bars. Defaults to "block".

None

colors

Sequence[Union[Color, str]]

Colors of the bars.

['red', 'green', 'blue', 'yellow']

bgcolor

Union[Color, str]

Background color. Defaults to "default".

None

invert_negative

Literal[reverse, swap]

Use positive marks and invert cell colors for negative number. If None or not supported by marks, the cell is not inverted.

None

orientation

Orientation

(Literal["horizontal", "vertical"], optional): The orientation of the bar. Defaults to "horizontal".

'horizontal'

Stack

Stack(
    data,
    value_range,
    *,
    length=None,
    width=None,
    marks=None,
    colors=colors,
    bgcolor=None,
    invert_negative=None,
    orientation="horizontal",
    origin=None,
    force_origin=None,
    prefer_bg=None,
)

Stacked bar graph.

Parameters:

Name Type Description Default

data

Sequence[float]

The values in order of stacking.

required

value_range

Tuple[float, float]

Lower and upper boundary. Defaults to range of data.

required

length

int

The length of the graph. Defaults to 100.

None

width

int

The width of the bars. Defaults to 1.

None

marks

Union[BarMark, Mark]]

Marks used for the bars. Defaults to "block".

None

colors

Sequence[Union[Color, str]]

Colors of the bars.

colors

bgcolor

Union[Color, str]

Background color. Defaults to "default".

None

invert_negative

Literal[reverse, swap]

Use positive marks and invert cell colors for negative number. If None or not supported by marks, the cell is not inverted.

None

orientation

Orientation

(Literal["horizontal", "vertical"], optional): The orientation of the bar. Defaults to "horizontal".

'horizontal'

origin

float

Origin point. Defaults to 0.0.

None

force_origin

bool

Force origin to half cell grid. Defaults to False.

None

prefer_bg

OptimizationStrategy

Replace block characters with background, either "never", for "full" blocks only, or for all. Defaults to "full".

None

segments

segments(length=None)

Returns rendered bar segments.

Parameters:

Name Type Description Default

length

Optional[int]

Override bar graph length.

None

Yields: Segment: Next segment of rendered bar.