You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The charts class in rick.py should be reformatted for better readability and ability to be generalized.
Potential improvements are:
Replacing repeated code blocks with sub functions
Updating functions to be able to support different input sizes, specifically, any bar or line charts should be able to handle more than just 1 or 2 columns of data
For example, bar_chart only supports graphing 2 columns of data but this could be extended to any number of columns
Changing some class and function names for clarity
Outline of new structure
Plotting functions currently follow a relatively similar structure which could be replaced with the following functions (and potentially more):
calculate_y_params() # calculates the minimum, maximum and increment values for the y axis set_plot_style() # sets the grid, background color and size of the plot set_ticks() # sets the x and y ticksset_labels() # sets x and y axis labelsset_annotations() # adds any additional annotations to the plot set_legend() # adds a legend to the plot
Note: function arguments are in progress
A general plotting function would then follow the format below.
defexample_plotting_function(df, ylab, xlab, **kwargs):
''' Description of function including inputs, outputs and any kwargs. '''func() # Should be renamed to be more clear y_min, y_max, y_inc=calculate_y_params()
fig, ax=example_plot() # depends on each function fig, ax=set_plot_style()
fig, ax=set_ticks()
fig, ax=set_labels()
fig, ax=set_annotations()
fig, ax=set_legend()
returnfig, axdefexample_plot():
'''Description of function'''fori, colindata.columns:
## plot of specific type e.g. plot(data, ) for lines
Furthermore, the Charts class can be reorganized to use inheritance such that:
Charts contains all the functions that are common between the different chart types (the ones listed above) as methods
Each chart type (e.g. line, bar chart) is a child class that includes it's own plotting method
Context
The
charts
class inrick.py
should be reformatted for better readability and ability to be generalized.Potential improvements are:
bar_chart
only supports graphing 2 columns of data but this could be extended to any number of columnsOutline of new structure
Plotting functions currently follow a relatively similar structure which could be replaced with the following functions (and potentially more):
Note: function arguments are in progress
A general plotting function would then follow the format below.
Furthermore, the
Charts
class can be reorganized to use inheritance such that:Charts
contains all the functions that are common between the different chart types (the ones listed above) as methodsTo do
func
function to make it more intuitive what it is doing (e.g.init_global_settings
or something better)Charts
class to ensure that they work for any chart typeThe text was updated successfully, but these errors were encountered: