Line chart
Suppose you have continuous data that you would like to represent through a chart. A line chart is a good option. The line chart is especially effective when trying to identify a trend or pattern in your data, for example.
The method is
shimoku.plt.line()
It must contain the following input variables:
data: Union[str, DataFrame, List[Dict]]
x: str
y: List[str]
menu_path: str
order: int
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]]
And it may be personalized with the input variables:
option_modifications: Optional[Dict]
If the code runs with data, menu_path and axes configured as this:
data = [
{'date': dt.date(2021, 1, 1), 'x': 5, 'y': 3},
{'date': dt.date(2021, 1, 2), 'x': 5, 'y': 7},
{'date': dt.date(2021, 1, 3), 'x': 4, 'y': 5},
{'date': dt.date(2021, 1, 4), 'x': 7, 'y': 6},
{'date': dt.date(2021, 1, 5), 'x': 3, 'y': 5},
]
â
shimoku.plt.line(
data=data,
x='date', y=['x', 'y'],
menu_path='test/line-1',
order=0,
rows_size=2, cols_size=12,
)
The result is:

The line with the default configuration.
It is possible to personalize the title of the chart, adding data points, name for each axis, the legend, size and space occupied. One example could be obtained using:
data = [
{'date': dt.date(2021, 1, 1), 'new': 4, 'vac': 5},
{'date': dt.date(2021, 1, 2), 'new': 7, 'vac': 6},
{'date': dt.date(2021, 1, 3), 'new': 4, 'vac': 7},
{'date': dt.date(2021, 1, 4), 'new': 9, 'vac': 8},
{'date': dt.date(2021, 1, 5), 'new': 3, 'vac': 9},
{'date': dt.date(2021, 1, 6), 'new': 6, 'vac': 2},
]
â
shimoku.plt.line(
data=data,
x='date', y=['new', 'vac'],
menu_path='test/line-2',
order=0,
rows_size=2, cols_size=9,
padding='0,0,0,2',
title='Positive Results in the first six days - January',
option_modifications = {'dataZoom': False}
)
Set
{'dataZoom': False}
to remove the Zoom bar.The result is:

Modifying data points, adding a title, legend, and other personalization. Note the space before the component using
padding='0,0,0,2'.
It is possible to use any number of rows.
Last modified 8mo ago