Line and Bar

This hybrid chart fuses the visual appeal of both line and bar graphs. While the line graph depicts the trend or continuous data, the bars offer a clear representation of discrete data points. The dual y-axis design facilitates the comparison of two related but differently scaled sets of data. This configuration is especially helpful when one wants to showcase a correlation or interaction between two distinct yet interconnected data sets.

The Method To Use

The method is s.plt.line_and_bar_charts()

It must contain the following input variables:

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

And accepts the following input variables as optional:

bar_names: Optional[List[str]] = None
line_names: Optional[List[str]] = None
x_axis_name: Optional[str] = None
bar_axis_name: Optional[str] = None
bar_suffix: Optional[str] = None,
line_axis_name: Optional[str] = None
line_suffix: Optional[str] = None
title: Optional[str] = None
rows_size: Optional[int] = None
cols_size: Optional[int] = None
padding: Optional[List[int]] = None
option_modifications: Optional[Dict] = None
variant: Optional[str] = None

Examples

The following code:

data = [
    {'day': 'Mon', 'Evaporation': 2.0, 'Precipitation': 2.6, 'Temperature': 2.0},
    {'day': 'Tue', 'Evaporation': 4.9, 'Precipitation': 5.9, 'Temperature': 2.2},
    {'day': 'Wed', 'Evaporation': 7.0, 'Precipitation': 9.0, 'Temperature': 3.3},
    {'day': 'Thu', 'Evaporation': 23.2, 'Precipitation': 26.4, 'Temperature': 4.5},
    {'day': 'Fri', 'Evaporation': 25.6, 'Precipitation': 28.7, 'Temperature': 6.3},
    {'day': 'Sat', 'Evaporation': 76.7, 'Precipitation': 70.7, 'Temperature': 10.2},
    {'day': 'Sun', 'Evaporation': 135.6, 'Precipitation': 175.6, 'Temperature': 20.3}
]

s.plt.line_and_bar_charts(
    data=data, order=0, x='day', 
    bar_names=['Evaporation', 'Precipitation'], 
    line_names=['Temperature'],
    title='rainfall and temperature', 
    x_axis_name='Day', 
    line_axis_name='Temperature',
    line_suffix=' °C', 
    bar_axis_name='Evaporation and precipitacion', 
    bar_suffix=' ml'
)

Variants

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

Last updated