in charts/builder.py [0:0]
def boxplot(title, ylabel, xlabel, data, value_column, ax, operations, box_colors):
"""
Create a box plot (box-and-whisker plot with mean line) to visualize the distribution of performance values
for different products (Elasticsearch and OpenSearch) and compare their distributions.
Parameters:
title (str): Title for the plot.
ylabel (str): Label for the y-axis of the plot.
xlabel (str): Label for the x-axis of the plot.
data (pandas.DataFrame): DataFrame containing performance data.
value_column (str): The column in the DataFrame containing the performance values.
ax (matplotlib.axes._subplots.AxesSubplot): Matplotlib AxesSubplot object to plot the box plot.
operations (list): List of operations to include in the analysis.
box_colors (list): List of colors for the boxes in the box plot.
"""
data = data[(data['operation'].isin(operations))]
grouped_data = data.groupby('user-tags.product')[value_column].apply(list).reset_index(name=value_column)
bp = ax.boxplot(
grouped_data[value_column],
labels=grouped_data['user-tags.product'],
patch_artist=True,
showmeans=True,
meanline=True,
notch=False,
medianprops = {'linestyle': '-', 'linewidth': 1, 'color': 'black'},
flierprops={'marker': '.', 'markersize': 1},
meanprops={'linestyle': ':', 'linewidth': 1, 'color': 'white'}
)
for box, color in zip(bp['boxes'], box_colors):
box.set(facecolor=color)
for median in bp['medians']:
median.set_color('black')
ax.set_title(title)
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
ax.tick_params(axis='both', labelsize=8)