Shimoku docs
Search…
Bar chart
A bar chart uses vertical bars to show comparisons between categories of data. Vertical bar charts illustrate sizes of data using different bar heights.

The method to use

The method is shimoku.plt.bar()
It must contain the following input variables:
data: Union[str, DataFrame, List[Dict]]
x: str
y: List[str]
menu_path: str
order: int
And accepts the following input variables as optional:
title: Optional[str]
x_axis_name: Optional[str]
y_axis_name: Optional[str]
rows_size: Optional[int]
cols_size: Optional[int]
padding: Optional[List[int]]
Additionally, it can be personalized with the input variables:
option_modifications: Optional[Dict]

Video demonstration of the bar chart

Bar chart settings and usage.

Examples

1. Default configuration

data = [
{'date': dt.date(2021, 1, 1), 'x': 1, 'y': 10},
{'date': dt.date(2021, 1, 2), 'x': 2, 'y': 8},
{'date': dt.date(2021, 1, 3), 'x': 3, 'y': 10},
{'date': dt.date(2021, 1, 4), 'x': 4, 'y': 2},
{'date': dt.date(2021, 1, 5), 'x': 5, 'y': 14},
]
shimoku.plt.bar(
data=data,
x='date', y=['x', 'y'],
menu_path='test/bar-1',
order=0,
rows_size=2, cols_size=9,
)
The result is:
The bar chart is in the default configuration, with cols_size=9, the maximum is 12. One can hide and show the columns of a data set by clicking on the small coloured square x or y.

2. Title, axes names, legend, size and padding

It is possible to personalize the title of the chart, name of each axis, the legend, changing size and add padding. One example could be obtained using:
data = [
{'date': dt.date(2021, 1, 1), 'store 1': 5, 'store 2': 10},
{'date': dt.date(2021, 2, 1), 'store 1': 6, 'store 2': 8},
{'date': dt.date(2021, 3, 1), 'store 1': 4, 'store 2': 10},
{'date': dt.date(2021, 4, 1), 'store 1': 7, 'store 2': 2},
{'date': dt.date(2021, 5, 1), 'store 1': 3, 'store 2': 14},
{'date': dt.date(2021, 6, 1), 'store 1': 7, 'store 2': 12},
]
shimoku.plt.bar(
data=data,
x='date', y=['store 1', 'store 2'],
x_axis_name='date',
y_axis_name='revenue / store',
title='Revenue per store, first half - 2021',
menu_path='test/bar-2',
order=0,
rows_size=2, cols_size=10,
padding='0,0,0,1',
)
The result is:
Note the space before the component with padding='0,0,0,1', the size with cols_size=10, and the text added.
And if you want to show just one variable, for example Height, you can edit the data frame like this:
data = [
{'date': 'Jan', 'Height': 3},
{'date': 'Feb', 'Height': 3.5},
{'date': 'Mar', 'Height': 4.2},
{'date': 'Apr', 'Height': 5},
{'date': 'May', 'Height': 5.8},
{'date': 'Jun', 'Height': 6.3},
]
shimoku.plt.bar(
data=data,
x='date', y=['Height'],
menu_path='test/bar-3',
order=0,
rows_size=2, cols_size=10,
padding='0,0,0,1',
title='Evolution: Average Height of 1000 Trees - 2021'
option_modifications={'dataZoom': False},
)
The result is:
Bar chart for one variable, fully customized.
Changing menu_path The menu_path can be modified.
It is possible to use any number of rows.
Copy link
On this page
The method to use
Examples