Horizontal Bar

The horizontal bar chart can display the category labels in a natural, easy-to-read manner. If the labels are long they will not overlap. The data can be plotted horizontally, meaning that the longer the bar the larger the category. This is a good way to present data with long labels that would be hard to display below a vertical bar.

The Method To Use

The method is s.plt.horizontal_bar()

It must contain the following input variables:

x: str
order: int
data: Union[str, DataFrame, List[Dict]]

Accepts the following input variables as optional:

y: Optional[List[str]]
x_axis_name: Optional[str]
y_axis_name: Optional[str]
title: Optional[str]
rows_size: Optional[int]
cols_size: Optional[int]
padding: Optional[List[int]]
show_values: Optional[List[str]]
option_modifications: Optional[Dict]
variant: Optional[str]

Examples

1. Default Configuration

data = [
    {'Name': 'd', 'y': 6, 'z': 3},
    {'Name': 'c', 'y': 7, 'z': 1},
    {'Name': 'b', 'y': 3, 'z': 5},
    {'Name': 'a', 'y': 5, 'z': 6},
]

s.plt.horizontal_bar(
    data=data, x='Name', order=0,
    rows_size=2, cols_size=12,
)

2. Customization And Context

It is possible to personalize the title of the chart, its subtitle, name of each axis, the legend, its size and add padding. One example could be obtained using:

data = [
    {'Count': 'Ph 1', 'Hours': 6, 'People': 3},
    {'Count': 'Ph 2', 'Hours': 7, 'People': 1},
    {'Count': 'Ph 3', 'Hours': 3, 'People': 5},
    {'Count': 'Ph 4', 'Hours': 5, 'People': 6},
]

s.plt.horizontal_bar(
    data=data, x='Count', 
    order=0, rows_size=2, cols_size=10,
    padding='0,0,0,1', title='Working Hours and Resources',
)

Variants

By setting the parameter variant to the following values the appearance of the chart can be changed:

Changing the Menu Path The menu_path can be modified.

Using the Grid

It is possible to use any number of rows.

Last updated