Scatter plot
A scatter plot, or chart, uses dots to represent numerical values for two variables. The position of each dot on the horizontal and vertical axis indicates the values for each data point. Scatter plots are used to verify relationships between variables.
The method is
shimoku.plt.scatter()
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': 6, '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.scatter(
data=data,
x='date', y=['x', 'y'],
menu_path='test/scatter-1',
order=0,
)
The result is:

The scatter plot in 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), 'store 1': 5, 'store 2': 3},
{'date': dt.date(2021, 1, 2), 'store 1': 6, 'store 2': 7},
{'date': dt.date(2021, 1, 3), 'store 1': 4, 'store 2': 5},
{'date': dt.date(2021, 1, 4), 'store 1': 7, 'store 2': 6},
{'date': dt.date(2021, 1, 5), 'store 1': 3, 'store 2': 5},
{'date': dt.date(2021, 1, 6), 'store 1': 6, 'store 2': 1},
{'date': dt.date(2021, 1, 7), 'store 1': 3, 'store 2': 5},
]
shimoku.plt.scatter(
data=data,
x='date', y=['store 1', 'store 2'],
menu_path='test/scatter-2',
order=0, rows_size=2, cols_size=11,
padding="0,0,0,1",
title="Orders (10k)",
x_axis_name="date",
option_modifications={'dataZoom': False},
)
The result is:

The zoom bar was removed using
option_modifications={'dataZoom': False}
, note the space before the component using padding="0,0,0,1",
and the reduction in size with cols_size=11
.Last modified 8mo ago