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

Add figsize parameter to get_patterns() for customizable plot sizes #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lshpaner
Copy link

Changes Summary

  1. Added figsize Parameter in get_patterns() Method:

    • Introduced a new parameter figsize to the get_patterns() method, which allows the user to specify the size of the figure when plotting the missing data patterns.
    • Default value is set to (10, 8), which can be overridden by the user.
    • Passed the figsize parameter to the _make_plot() method.
def get_patterns(
    self, 
    X: Matrix, 
    count_or_proportion: str = "count", 
    show_plot: bool = True, 
    figsize: tuple = (10, 8)  # Added figsize as an optional parameter
) -> pd.DataFrame:
    # Other code remains the same
    
    # Pass the figsize to the _make_plot method
    if show_plot:
        self._make_plot(figsize=figsize)

    return self.md_patterns
  1. Modified _make_plot() Method to Accept figsize:

    • Updated the _make_plot() method to accept the figsize parameter.
    • This figsize is used when creating the plt.subplots to determine the size of the plot.
def _make_plot(self, figsize: tuple = (10, 8)):
    """"Creates visualization of missing data patterns"""
    
    # Other code remains the same
    
    fig, ax = plt.subplots(figsize=figsize)  # Use the figsize passed as an argument
    
    # Remaining code for plotting
    plt.show()

How It Works Now

  • When you call get_patterns() on an instance of mdPatterns, you can pass the figsize parameter to specify the size of the plot.

  • The figsize is then used in the _make_plot() method to create the plot with the desired dimensions.

New Implementation

mdp = mdPatterns()
patterns = mdp.get_patterns(X=your_data, figsize=(12, 10))  # Custom figure size

This change provides flexibility to the end user, allowing them to adjust the size of the plot, which helps in preventing issues like scrunched-up labels when dealing with datasets that have many columns or rows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant