LSYS/forestplot

Feature Request: Customizable Column Name Option in forestplot

Closed this issue · 4 comments

Summary:

I would like to propose a feature enhancement for the forestplot package that allows users to specify custom column names instead of the default "Variable" label. This feature would be handy for those looking to compare models or other items that require more descriptive column naming.

Current Behavior:

Currently, the forestplot package automatically assigns the name "Variable" to one of its columns. While this works well for general purposes, it needs more flexibility for cases where a different label might be more appropriate or informative (I could change it for my use cases, but it can be difficult for some users).
For example, in one of your sample codes, we can see that the first column of the forestplot is Variable:

fp.forestplot(df,  # the dataframe with results data
              estimate="r",  # col containing estimated effect size 
              ll="ll", hl="hl",  # lower & higher limits of conf. int.
              varlabel="label",  # column containing the varlabels to be printed on far left
              capitalize="capitalize",  # Capitalize labels
              pval="p-val",  # column containing p-values to be formatted
              annote=["n", "power", "est_ci"],  # columns to report on left of plot
              annoteheaders=["N", "Power", "Est. (95% Conf. Int.)"],  # ^corresponding headers
              rightannote=["formatted_pval", "group"],  # columns to report on right of plot 
              right_annoteheaders=["P-value", "Variable group"],  # ^corresponding headers
              xlabel="Pearson correlation coefficient",  # x-label title
              table=True,  # Format as a table
              )

Proposed Feature:

I suggest adding an option allowing users to specify their column names. This could be implemented as an additional argument in the relevant function(s), allowing users to choose a custom name that better fits their data or the context of their analysis.

Use Case:

For instance, in scenarios where users are comparing different models (e.g., prediction models like 'Regression', 'Random Forest', 'SVM'), having the ability to label the column as "Prediction Models" or a similar custom name would enhance the readability and relevance of the forestplot.

Benefits:

  • Enhanced Customization: Users can tailor the forestplot to fit the context of their data better.
  • Increased Clarity: Custom column names can make the plots more intuitive and informative, especially for presentations or publications.
  • Broader Applicability: This feature could broaden the use cases for the forestplot package, making it more versatile for various data analyses.

Thank you for considering this feature request. I believe it would be a valuable addition to the forestplot package and enhance its utility for a wide range of users.

Best regards,
@kamalakbari7

LSYS commented

Hi there @kamalakbari7, thanks so much for raising this. In short, I anticipated this need but completely forgot to document it.

It's already implemented via the variable_header arg (currently undocumented).

Here's an example:

import forestplot as fp

df = fp.load_data("sleep")

fp.forestplot(df,  # the dataframe with results data
              estimate="r",  # col containing estimated effect size 
              ll="ll", hl="hl",  # lower & higher limits of conf. int.
              varlabel="label",  # column containing the varlabels to be printed on far left
              capitalize="capitalize",  # Capitalize labels
              pval="p-val",  # column containing p-values to be formatted
              annote=["n", "power", "est_ci"],  # columns to report on left of plot
              annoteheaders=["N", "Power", "Est. (95% Conf. Int.)"],  # ^corresponding headers
              rightannote=["formatted_pval", "group"],  # columns to report on right of plot 
              right_annoteheaders=["P-value", "Variable group"],  # ^corresponding headers
              xlabel="Pearson correlation coefficient",  # x-label title
              table=True,  # Format as a table
              variable_header="custom header",
            )

image

LSYS commented

will need to document it or include it in the FAQs when I get to that.

This issue is stale because it has been open for 30 days with no activity.

This issue was closed because it has been inactive.