#!/usr/bin/env python # coding: utf-8 # In[1]: import pandas as pd import forestplot as fp # ## Top of plot should not be getting cut off # See issue [#47](https://github.com/LSYS/forestplot/issues/47) # In[2]: df = pd.read_csv("../examples/data/regression1.csv") df # In[3]: fp.forestplot(df, # the dataframe with results data estimate='or', # col containing estimated effect size ll='low', hl='high', # columns containing conf. int. lower and higher limits varlabel='varname', # column containing variable label ylabel='Confidence interval', # y-label title xlabel='Odds Ratio', # x-label title color_alt_rows=True, figsize=(4,8), **{ 'xline' : 1., "xlinestyle": (0, (10, 5)), # long dash for x-reference line } ) # ## Capitalization of strings should be preserved # In[4]: df = pd.read_csv("../examples/data/sleep.csv") df # In[5]: fp.forestplot(df, # the dataframe with results data estimate="r", # col containing estimated effect size ll="ll", hl="hl", # columns containing conf. int. lower and higher limits varlabel="label", # column containing variable label ylabel="Confidence interval", # y-label title xlabel="Pearson correlation", # x-label title ) # ## Kwargs for p-value thresholds and symbols should be respected # In[6]: fp.forestplot(df, # the dataframe with results data estimate="r", # col containing estimated effect size ll="ll", hl="hl", # columns containing conf. int. lower and higher limits varlabel="label", # column containing variable label pval="p-val", # Column of p-value to be reported on right decimal_precision=3, symbols=("$^a$", "$^b$", "$^c$"), thresholds=(0.001, 0.01, 0.05) ) # ## CI label and P-value label should have same height fontsize # In[7]: fp.forestplot(df, # the dataframe with results data estimate="r", # col containing estimated effect size ll="ll", hl="hl", # columns containing conf. int. lower and higher limits varlabel="label", # column containing variable label pval="p-val", # Column of p-value to be reported on right ylabel="Confidence interval", # ylabel to print ) # ## > 6 rows should work # In[10]: 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 ) # ## $\leq$ 6 rows should work # In[12]: fp.forestplot(df.head(6), # 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 ) # In[14]: fp.forestplot(df.head(3), # 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 ) # In[ ]: # In[ ]: