Skip to content

Commit

Permalink
#8 add vertical_grouped_bar_chart
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhangyixue1537 committed Jun 6, 2024
1 parent 2dc72f5 commit 418ad97
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions rick.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,66 @@ def horizontal_grouped_bar_chart(data: pd.DataFrame, **kwargs: dict) -> (plt.fig
**kwargs
)

def vertical_grouped_bar_chart(data: pd.DataFrame, **kwargs: dict) -> (plt.figure, plt.axes):
'''
Creates a vertical grouped bar chart. Number of bars in
each group to plot is determined from the number of
columns in input dataframe, while the number of groups is
determined by the number of rows.
Parameters
-----------
Required:
data : pd.DataFrame
Data for the grouped bar chart.
Optional:
ylab : str
Label for the y axis.
xlab : str
Label for the x axis.
ymax : float
The max value of the y axis.
ymin : float
The minimum value of the y axis
Should include this if minimum < 0.
yinc : float
The increment of ticks on the y axis.
ax : plt.axes
The axis that the plot will be located on.
plot_size : (int, int)
Custom plot dimensions.
precision : int
Decimal points in the annotations.
percent : int
Flag determining whether to show percentage change between
baseline column (assumed to be the first column) and
remaining columns.
additional_annotations : dict
Dictionary with keys of type (int, int) and values
of type (str), indicating the coordinates and
annotation to be added.
legend : list[str]
A list of string objects to be used for the legend.
Returns
--------
fig
Matplotlib fig object
ax
Matplotlib ax object
'''
return general_grouped_bar_chart(
data=data,
param_axis='y',
index_axis='x',
horizontal=False,
standard_plot_size=(len(data)*1.5, 6.1),
grid_x=False,
**kwargs
)

def multi_linechart(data:pd.DataFrame, ylab:str, xlab:str, **kwargs:dict) -> (plt.figure, plt.axes):
'''
Creates a line chart of one or more lines.
Expand Down

0 comments on commit 418ad97

Please sign in to comment.