Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacked bar plots helper function #525

Closed
3 tasks
zjpoh opened this issue Jul 25, 2018 · 1 comment
Closed
3 tasks

Stacked bar plots helper function #525

zjpoh opened this issue Jul 25, 2018 · 1 comment
Labels
level: intermediate python coding expertise required type: feature a new visualizer or utility for yb

Comments

@zjpoh
Copy link
Contributor

zjpoh commented Jul 25, 2018

Create a helper function in the yellowbrick.draw module that can create a stacked bar chart from a 2D array on the specified axes. This function should have the following basic signature:

def bar_stack(data, ax=None, labels=None, ticks=None, colors=None, **kwargs):
    """
    An advanced bar chart plotting utility that can draw bar and stacked bar charts from
    data, wrapping calls to the specified matplotlib.Axes object. 

    Parameters
    ----------
    data : 2D array-like 
        The data associated with the bar chart where the columns represent each bar
        and the rows represent each stack in the bar chart. A single bar chart would 
        be a 2D array with only one row, a bar chart with three stacks per bar would 
        have a shape of (3, b).  

    ax : matplotlib.Axes, default: None
        The axes object to draw the barplot on, uses plt.gca() if not specified.

    labels : list of str, default: None
        The labels for each row in the bar stack, used to create a legend. 

    ticks : list of str, default: None
        The labels for each bar, added to the x-axis for a vertical plot, or the y-axis
        for a horizontal plot.  

    colors : array-like, default: None
        Specify the colors of each bar, each row in the stack, or every segment. 

    kwargs : dict 
        Additional keyword arguments to pass to ``ax.bar``. 
    """

This is just a base signature and should be further refined as we dig into the work. Once this helper function is created, the following visualizers should be updated to use it:

  • PosTagVisualizer
  • FeatureImportances
  • ClassPredictionError

(@DistrictDataLabs/team-oz-maintainers please feel free to add other visualizers above as needed)

Describe the solution you'd like
A helper function to create stacked bar plot. (See #510 and #847, #771 )

Is your feature request related to a problem? Please describe.
This can be useful for ClassPredictionError, FeatureImportances, and future stacked bar plot.

@rebeccabilbro rebeccabilbro added type: feature a new visualizer or utility for yb level: intermediate python coding expertise required bc-hack labels Aug 20, 2018
@bbengfort bbengfort changed the title Helper function for stack bar plots Stacked bar plots helper function May 28, 2019
@lwgray
Copy link
Contributor

lwgray commented May 28, 2019

@zjpoh thank you for submitting this feature request.

Kautumn06 pushed a commit to Kautumn06/yellowbrick that referenced this issue Jun 4, 2019
Reworded the description of the data parameter to help clarify the shape
of data needed for a single bar chart and a bar chart with three stacks
per bar.

See also: Issue DistrictDataLabs#525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level: intermediate python coding expertise required type: feature a new visualizer or utility for yb
Projects
None yet
Development

No branches or pull requests

3 participants