{"id":15805302,"url":"https://github.com/lsys/forestplot","last_synced_at":"2025-04-07T12:09:10.372Z","repository":{"id":41802456,"uuid":"510013191","full_name":"LSYS/forestplot","owner":"LSYS","description":"A Python package to make publication-ready but customizable coefficient plots.","archived":false,"fork":false,"pushed_at":"2024-07-28T07:20:29.000Z","size":8791,"stargazers_count":111,"open_issues_count":6,"forks_count":10,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-06T02:07:44.816Z","etag":null,"topics":["coefficientplot","data-science","data-visualization","dataviz","forestplot","matplotlib","python","visualization"],"latest_commit_sha":null,"homepage":"http://forestplot.rtfd.io","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LSYS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"citation.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-03T12:11:42.000Z","updated_at":"2024-10-01T03:43:57.000Z","dependencies_parsed_at":"2023-12-14T04:25:07.355Z","dependency_job_id":"e28b4c79-bc53-4c43-86c2-4e104e5b62ca","html_url":"https://github.com/LSYS/forestplot","commit_stats":{"total_commits":169,"total_committers":3,"mean_commits":"56.333333333333336","dds":"0.023668639053254448","last_synced_commit":"b7591e3be7004f9962fd7cd7f91aa4cac91c45fc"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LSYS%2Fforestplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LSYS%2Fforestplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LSYS%2Fforestplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LSYS%2Fforestplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LSYS","download_url":"https://codeload.github.com/LSYS/forestplot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648977,"owners_count":20972945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coefficientplot","data-science","data-visualization","dataviz","forestplot","matplotlib","python","visualization"],"created_at":"2024-10-05T02:08:02.859Z","updated_at":"2025-04-07T12:09:10.347Z","avatar_url":"https://github.com/LSYS.png","language":"Jupyter Notebook","readme":"\u003cdiv id=\"top\"\u003e\u003c/div\u003e \n\u003ch1 align=\"center\" \u003e\n  Forestplot\n\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pypi.org/project/forestplot\"\u003e\n  \u003cimg alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/forestplot?label=Python\u0026logo=python\u0026logoColor=white\"\u003e\n  \u003c/a\u003e\u003cbr\u003e\n  \u003cb\u003eEasy API for forest plots.\u003c/b\u003e\u003cbr\u003e\n  A Python package to make publication-ready but customizable forest plots.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cimg width=\"100%\" src=\"https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/main.png\"\u003e\u003c/p\u003e\n\n-----------------------------------------------------------\nThis package makes publication-ready forest plots easy to make out-of-the-box. Users provide a `dataframe` (e.g. from a spreadsheet) where rows correspond to a variable/study with columns including estimates, variable labels, and lower and upper confidence interval limits.\nAdditional options allow easy addition of columns in the `dataframe` as annotations in the plot.\n\n\u003c!---------------------- Project shields ----------------------\u003e\n\n|    |    |\n| --- | --- |\n| Release | [![PyPI](https://img.shields.io/pypi/v/forestplot?color=blue\u0026label=PyPI\u0026logo=pypi\u0026logoColor=white)](https://pypi.org/project/forestplot/) [![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/forestplot?logo=conda-forge\u0026logoColor=white)](https://anaconda.org/conda-forge/forestplot) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/lsys/forestplot?color=blue\u0026label=Latest%20release)](https://github.com/LSYS/forestplot/releases) |\n| Status | [![CI](https://github.com/LSYS/forestplot/actions/workflows/CI.yml/badge.svg)](https://github.com/LSYS/forestplot/actions/workflows/CI.yml) [![Notebooks](https://github.com/LSYS/forestplot/actions/workflows/nb.yml/badge.svg)](https://github.com/LSYS/forestplot/actions/workflows/nb.yml) |\n| Coverage |  [![Codecov](https://img.shields.io/codecov/c/github/lsys/forestplot?logo=codecov\u0026logoColor=white\u0026label=codecov)](https://app.codecov.io/gh/LSYS/forestplot) |\n| Python | [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/forestplot?label=Python%203.6%2B\u0026logo=python\u0026logoColor=white)](https://pypi.org/project/forestplot/) |\n| Docs | [![Read the Docs (version)](https://img.shields.io/readthedocs/forestplot/stable?label=docs\u0026logo=readthedocs\u0026logoColor=white)](https://forestplot.readthedocs.io/en/latest/?badge=latest) [![DocLinks](https://github.com/LSYS/forestplot/actions/workflows/links.yml/badge.svg)](https://github.com/LSYS/forestplot/actions/workflows/links.yml)|\n| Meta | [![GitHub](https://img.shields.io/github/license/lsys/forestplot?color=purple\u0026label=License)](https://choosealicense.com/licenses/mit/) [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat\u0026labelColor=ef8336)](https://pycqa.github.io/isort/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![types - Mypy](https://img.shields.io/badge/types-Mypy-blue.svg)](https://github.com/python/mypy) [![DOI](https://zenodo.org/badge/510013191.svg)](https://zenodo.org/badge/latestdoi/510013191) |\n| Binder| [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/lsys/forestplot/main?labpath=examples%2Freadme-examples.ipynb) |\n\n\u003c!---------------------- TABLE OF CONTENT ----------------------\u003e\n# Table of Contents[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#table-of-contents)\n\u003cdetails open\u003e\u003csummary\u003e\u003cb\u003eshow/hide\u003c/b\u003e\u003c/summary\u003e\u003cp\u003e\n\n\u003e - [Installation](#installation)\n\u003e - [Quick Start](#quick-start)\n\u003e - [Some Examples with Customizations](#some-examples-with-customizations)\n\u003e - [Gallery and API Options](#gallery-and-api-options)\n\u003e - [Multi-models](#multi-models)\n\u003e - [Known Issues](#known-issues)\n\u003e - [Background and Additional Resources](#background-and-additional-resources)\n\u003e - [Contributing](#contributing)\n\u003c/p\u003e\u003c/details\u003e\u003cp\u003e\u003c/p\u003e\n\n\u003c!------------------------- INSTALLATION -------------------------\u003e\n## Installation[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#installation)\n\nInstall from PyPI\u003cbr\u003e\n [![PyPI](https://img.shields.io/pypi/v/forestplot?color=blue\u0026label=PyPI\u0026logo=pypi\u0026logoColor=white)](https://pypi.org/project/forestplot/)\n```bash\npip install forestplot\n```\n\nInstall from conda-forge\u003cbr\u003e\n[![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/forestplot?logo=conda-forge\u0026logoColor=white)](https://anaconda.org/conda-forge/forestplot)\n```bash\nconda install forestplot\n```\n\nInstall from source\u003cbr\u003e\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/lsys/forestplot?color=blue\u0026label=Latest%20release)](https://github.com/LSYS/forestplot/releases)\u003cbr\u003e\n```bash\ngit clone https://github.com/LSYS/forestplot.git\ncd forestplot\npip install .\n```\n\nDeveloper installation\u003cbr\u003e\n```bash\ngit clone https://github.com/LSYS/forestplot.git\ncd forestplot\npip install -r requirements_dev.txt\n\nmake lint\nmake test\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!------------------------- QUICK START -------------------------\u003e\n## Quick Start[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#quick-start)\n\n```python\nimport forestplot as fp\n\ndf = fp.load_data(\"sleep\")  # companion example data\ndf.head(3)\n```\n|    | var      |          r |   moerror | label                     | group         |    ll |    hl |   n |    power |     p-val |\n|---:|:---------|-----------:|----------:|:--------------------------|:--------------|------:|------:|----:|---------:|----------:|\n|  0 | age      |  0.0903729 | 0.0696271 | in years                  | age           |  0.02 |  0.16 | 706 | 0.671578 | 0.0163089 |\n|  1 | black    | -0.0270573 | 0.0770573 | =1 if black               | other factors | -0.1  |  0.05 | 706 | 0.110805 | 0.472889  |\n|  2 | clerical |  0.0480811 | 0.0719189 | =1 if clerical worker     | occupation    | -0.03 |  0.12 | 706 | 0.247768 | 0.201948  |\n\n(* This is a toy example of how certain factors correlate with the amount of sleep one gets. See the [notebook that generates the data](https://nbviewer.org/github/LSYS/forestplot/blob/main/examples/get-sleep.ipynb).)\n\n\u003cdetails\u003e\u003csummary\u003e\u003ci\u003eThe example input dataframe above have 4 key columns\u003c/i\u003e\u003c/summary\u003e\n\n  | Column    | Description                                     | Required  |\n  |:----------|:------------------------------------------------|:----------|\n  | `var`     | Variable label                                  | \u0026check;   |\n  | `r`       | Correlation coefficients (estimates to plot)    | \u0026check;   |\n  | `label`   | Variable labels                                 | \u0026check;   |\n  | `group`   | Variable grouping labels                        |           |\n  | `ll`      | Conf. int. *lower limits*                       |           |\n  | `hl`      | Containing the conf. int. *higher limits*       |           |\n  | `n`       | Sample size                                     |           |\n  | `power`   | Statistical power                               |           |\n  | `p-val`   | P-value                                         |           |\n\n  (See [Gallery and API Options](#gallery-and-api-options) for more details on required and optional arguments.)  \n\u003c/details\u003e\n\nMake the forest plot\n```python\nfp.forestplot(df,  # the dataframe with results data\n              estimate=\"r\",  # col containing estimated effect size \n              ll=\"ll\", hl=\"hl\",  # columns containing conf. int. lower and higher limits\n              varlabel=\"label\",  # column containing variable label\n              ylabel=\"Confidence interval\",  # y-label title\n              xlabel=\"Pearson correlation\",  # x-label title\n              )\n```\n\u003cp align=\"left\"\u003e\u003cimg width=\"75%\" src=\"https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/vanilla.png\"\u003e\u003c/p\u003e\n\nSave the plot\n```python\nplt.savefig(\"plot.png\", bbox_inches=\"tight\")\n```\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!------------------ EXAMPLES of CUSTOMIZATIONS ------------------\u003e\n## Some Examples With Customizations[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#some-examples-with-customizations)\n\n1. Add variable groupings, add group order, and sort by estimate size.\n```python\nfp.forestplot(df,  # the dataframe with results data\n              estimate=\"r\",  # col containing estimated effect size \n              ll=\"ll\", hl=\"hl\",  # columns containing conf. int. lower and higher limits              \n              varlabel=\"label\",  # column containing variable label\n              capitalize=\"capitalize\",  # Capitalize labels\n              groupvar=\"group\",  # Add variable groupings \n              # group ordering\n              group_order=[\"labor factors\", \"occupation\", \"age\", \"health factors\", \n                           \"family factors\", \"area of residence\", \"other factors\"],\n              sort=True  # sort in ascending order (sorts within group if group is specified)               \n              )\n```\n\u003cp align=\"left\"\u003e\u003cimg width=\"75%\" src=\"https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/group-grouporder-sort.png\"\u003e\u003c/p\u003e\n\n2. Add p-values on the right and color alternate rows gray\n```python\nfp.forestplot(df,  # the dataframe with results data\n              estimate=\"r\",  # col containing estimated effect size \n              ll=\"ll\", hl=\"hl\",  # columns containing conf. int. lower and higher limits\n              varlabel=\"label\",  # column containing variable label\n              capitalize=\"capitalize\",  # Capitalize labels\n              groupvar=\"group\",  # Add variable groupings \n              # group ordering\n              group_order=[\"labor factors\", \"occupation\", \"age\", \"health factors\", \n                           \"family factors\", \"area of residence\", \"other factors\"],\n              sort=True,  # sort in ascending order (sorts within group if group is specified)               \n              pval=\"p-val\",  # Column of p-value to be reported on right\n              color_alt_rows=True,  # Gray alternate rows\n              ylabel=\"Est.(95% Conf. Int.)\",  # ylabel to print\n              **{\"ylabel1_size\": 11}  # control size of printed ylabel\n              )\n```\n\n\u003cp align=\"left\"\u003e\u003cimg width=\"80%\" src=\"https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/group-grouporder-pvalue-sort-colorrows.png\"\u003e\u003c/p\u003e\n\n\n3. Customize annotations and make it a table\n```python\nfp.forestplot(df,  # the dataframe with results data\n              estimate=\"r\",  # col containing estimated effect size \n              ll=\"ll\", hl=\"hl\",  # lower \u0026 higher limits of conf. int.\n              varlabel=\"label\",  # column containing the varlabels to be printed on far left\n              capitalize=\"capitalize\",  # Capitalize labels\n              pval=\"p-val\",  # column containing p-values to be formatted\n              annote=[\"n\", \"power\", \"est_ci\"],  # columns to report on left of plot\n              annoteheaders=[\"N\", \"Power\", \"Est. (95% Conf. Int.)\"],  # ^corresponding headers\n              rightannote=[\"formatted_pval\", \"group\"],  # columns to report on right of plot \n              right_annoteheaders=[\"P-value\", \"Variable group\"],  # ^corresponding headers\n              xlabel=\"Pearson correlation coefficient\",  # x-label title\n              table=True,  # Format as a table\n              )\n```\n\n\u003cp align=\"left\"\u003e\u003cimg width=\"85%\" src=\"https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/leftannote-rightannote-table.png\"\u003e\u003c/p\u003e\n\n4. Strip down all bells and whistle\n```python\nfp.forestplot(df,  # the dataframe with results data\n              estimate=\"r\",  # col containing estimated effect size \n              ll=\"ll\", hl=\"hl\",  # lower \u0026 higher limits of conf. int.\n              varlabel=\"label\",  # column containing the varlabels to be printed on far left\n              capitalize=\"capitalize\",  # Capitalize labels\n              ci_report=False,  # Turn off conf. int. reporting\n              flush=False,  # Turn off left-flush of text\n              **{'fontfamily': 'sans-serif'}  # revert to sans-serif                              \n              )\n```               \n\u003cp align=\"left\"\u003e\u003cimg width=\"50%\" src=\"https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/vcoefplot.png\"\u003e\u003c/p\u003e\n\n5. Example with more customizations\n```python\nfp.forestplot(df,  # the dataframe with results data\n              estimate=\"r\",  # col containing estimated effect size \n              ll=\"ll\", hl=\"hl\",  # lower \u0026 higher limits of conf. int.\n              varlabel=\"label\",  # column containing the varlabels to be printed on far left\n              capitalize=\"capitalize\",  # Capitalize labels\n              pval=\"p-val\",  # column containing p-values to be formatted\n              annote=[\"n\", \"power\", \"est_ci\"],  # columns to report on left of plot\n              annoteheaders=[\"N\", \"Power\", \"Est. (95% Conf. Int.)\"],  # ^corresponding headers\n              rightannote=[\"formatted_pval\", \"group\"],  # columns to report on right of plot \n              right_annoteheaders=[\"P-value\", \"Variable group\"],  # ^corresponding headers\n              groupvar=\"group\",  # column containing group labels\n              group_order=[\"labor factors\", \"occupation\", \"age\", \"health factors\", \n                           \"family factors\", \"area of residence\", \"other factors\"],                   \n              xlabel=\"Pearson correlation coefficient\",  # x-label title\n              xticks=[-.4,-.2,0, .2],  # x-ticks to be printed\n              sort=True,  # sort estimates in ascending order\n              table=True,  # Format as a table\n              # Additional kwargs for customizations\n              **{\"marker\": \"D\",  # set maker symbol as diamond\n                 \"markersize\": 35,  # adjust marker size\n                 \"xlinestyle\": (0, (10, 5)),  # long dash for x-reference line \n                 \"xlinecolor\": \"#808080\",  # gray color for x-reference line\n                 \"xtick_size\": 12,  # adjust x-ticker fontsize\n                }  \n              )\n```\n\u003cp align=\"left\"\u003e\u003cimg width=\"100%\" src=\"https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/main.png\"\u003e\u003c/p\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ci\u003eAnnotations arguments allowed include:\u003c/i\u003e\u003c/summary\u003e\n  \n  * `ci_range`: Confidence interval range (e.g. `(-0.39 to -0.25)`).\n  * `est_ci`: Estimate and CI (e.g. `-0.32(-0.39 to -0.25)`).\n  * `formatted_pval`: Formatted p-values (e.g. `0.01**`).\n  \n  To confirm what processed `columns` are available as annotations, you can do:\n  \n  ```python\n  processed_df, ax = fp.forestplot(df, \n                                   ...  # other arguments here\n                                   return_df=True  # return processed dataframe with processed columns\n                                  )\n  processed_df.head(3)\n  ```\n  \n  |    | label                | group         |   n |          r | CI95%         |       p-val |      BF10 |   power | var    |    hl |    ll |   moerror |   formatted_r |   formatted_ll |   formatted_hl | ci_range         | est_ci                | formatted_pval   |   formatted_n |   formatted_power | formatted_est_ci      | yticklabel                                                        | formatted_formatted_pval   | formatted_group   | yticklabel2            |\n|---:|:---------------------|:--------------|----:|-----------:|:--------------|------------:|----------:|--------:|:-------|------:|------:|----------:|--------------:|---------------:|---------------:|:-----------------|:----------------------|:-----------------|--------------:|------------------:|:----------------------|:------------------------------------------------------------------|:---------------------------|:------------------|:-----------------------|\n|  0 | Mins worked per week | Labor factors | 706 | -0.321384  | [-0.39 -0.25] | 1.99409e-18 | 1.961e+15 |    1    | totwrk | -0.25 | -0.39 | 0.0686165 |         -0.32 |          -0.39 |          -0.25 | (-0.39 to -0.25) | -0.32(-0.39 to -0.25) | 0.0***           |           706 |              1    | -0.32(-0.39 to -0.25) | Mins worked per week            706  1.0    -0.32(-0.39 to -0.25) | 0.0***                     | Labor factors     | 0.0***   Labor factors |\n|  1 | Years of schooling   | Labor factors | 706 | -0.0950039 | [-0.17 -0.02] | 0.0115515   | 1.137     |    0.72 | educ   | -0.02 | -0.17 | 0.0749961 |         -0.1  |          -0.17 |          -0.02 | (-0.17 to -0.02) | -0.10(-0.17 to -0.02) | 0.01**           |           706 |              0.72 | -0.10(-0.17 to -0.02) | Years of schooling              706  0.72   -0.10(-0.17 to -0.02) | 0.01**                     | Labor factors     | 0.01**   Labor factors |\n  \n\u003c/details\u003e\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!------------------- Multi-models -------------------\u003e\n## Multi-models[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#multi-models)\n\nFor coefficient plots where each variable can have multiple estimates (each `model` has one).\n\n```python\nimport forestplot as fp\n\ndf_mmodel = pd.read_csv(\"../examples/data/sleep-mmodel.csv\").query(\n    \"model=='all' | model=='young kids'\"\n)\ndf_mmodel.head(3)\n```\n\n|    | var   |       coef |       se |         T |     pval |       r2 |     adj_r2 |         ll |      hl | model      | group         | label       |\n|---:|:------|-----------:|---------:|----------:|---------:|---------:|-----------:|-----------:|--------:|:-----------|:--------------|:------------|\n|  0 | age   |   0.994889 |  1.96925 |  0.505213 | 0.613625 | 0.127289 |  0.103656  |   -2.87382 |  4.8636 | all        | age           | in years    |\n|  3 | age   |  22.634    | 15.4953  |  1.4607   | 0.149315 | 0.178147 | -0.0136188 |   -8.36124 | 53.6293 | young kids | age           | in years    |\n|  4 | black | -84.7966   | 82.1501  | -1.03222  | 0.302454 | 0.127289 |  0.103656  | -246.186   | 76.5925 | all        | other factors | =1 if black |\n\n```python\nfp.mforestplot(\n    dataframe=df_mmodel,\n    estimate=\"coef\",\n    ll=\"ll\",\n    hl=\"hl\",\n    varlabel=\"label\",\n    capitalize=\"capitalize\",\n    model_col=\"model\",\n    color_alt_rows=True,\n    groupvar=\"group\",\n    table=True,\n    rightannote=[\"var\", \"group\"],\n    right_annoteheaders=[\"Source\", \"Group\"],\n    xlabel=\"Coefficient (95% CI)\",\n    modellabels=[\"Have young kids\", \"Full sample\"],\n    xticks=[-1200, -600, 0, 600],\n    mcolor=[\"#CC6677\", \"#4477AA\"],\n    # Additional kwargs for customizations\n    **{\n        \"markersize\": 30,\n        # override default vertical offset between models (0.0 to 1.0)\n        \"offset\": 0.35,  \n        \"xlinestyle\": (0, (10, 5)),  # long dash for x-reference line\n        \"xlinecolor\": \".8\",  # gray color for x-reference line\n    },\n)\n```\n\u003cp align=\"left\"\u003e\u003cimg width=\"100%\" src=\"https://raw.githubusercontent.com/LSYS/forestplot/mplot-dev/docs/images/multimodel.png\"\u003e\u003c/p\u003e\n\nPlease note: This module is still experimental. See [this jupyter notebook](https://nbviewer.org/github/LSYS/forestplot/blob/mplot-dev/examples/test-multmodel-sleep.ipynb) for more examples and tweaks.\n\n\u003c!------------------- GALLERY AND API OPTIONS -------------------\u003e\n## Gallery and API Options[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#gallery-and-api-options)\n\n[![Notebooks](https://github.com/LSYS/forestplot/actions/workflows/nb.yml/badge.svg)](https://github.com/LSYS/forestplot/actions/workflows/nb.yml)\n\nCheck out [this jupyter notebook](https://nbviewer.org/github/LSYS/forestplot/blob/main/examples/readme-examples.ipynb) for a gallery variations of forest plots possible out-of-the-box.\nThe table below shows the list of arguments users can pass in.\nMore fined-grained control for base plot options (eg font sizes, marker colors) can be inferred from the [example notebook gallery](https://nbviewer.org/github/LSYS/forestplot/blob/main/examples/readme-examples.ipynb). \n\n\n| Option      | Description                                                                                                                                                 | Required   |\n|:-------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------|:---|\n| `dataframe`           | Pandas dataframe where rows are variables (or studies for meta-analyses) and columns include estimated effect sizes, labels, and confidence intervals, etc. | \u0026check; |\n| `estimate`            | Name of column in `dataframe` containing the *estimates*.                                                                                                   | \u0026check; |\n| `varlabel`            | Name of column in `dataframe` containing the *variable labels* (study labels if meta-analyses).                                                             | \u0026check; |\n| `ll`                  | Name of column in `dataframe` containing the conf. int. *lower limits*.                                                                                     |  |\n| `hl`                  | Name of column in `dataframe` containing the conf. int. *higher limits*.                                                                                    |  |\n| `logscale`            | If True, make the x-axis log scale. Default is False.                                                                                                     |  |\n| `capitalize`          | How to capitalize strings. Default is None. One of \"capitalize\", \"title\", \"lower\", \"upper\", \"swapcase\".                                                      | |\n| `form_ci_report`      | If True (default), report the estimates and confidence interval beside the variable labels.                                                                 |          |\n| `ci_report`           | If True (default), format the confidence interval as a string.                                                                                              |          |\n| `groupvar`            | Name of column in `dataframe` containing the variable *grouping labels*.                                                                                    |       |\n| `group_order`         | List of group labels indicating the order of groups to report in the plot.                                                                                  |       |\n| `annote`              | List of columns to add as annotations on the left-hand side of the plot.                                                                                    |       |\n| `annoteheaders`       | List of column headers for the left-hand side annotations.                                                                                                  |       |\n| `rightannote`         | List of columns to add as annotations on the right-hand side of the plot.                                                                                   |       |\n| `right_annoteheaders` | List of column headers for the right-hand side annotations.                                                                                                 |       |\n| `pval`                | Name of column in `dataframe` containing the p-values.                                                                                                      |       |\n| `starpval`            | If True (default), format p-values with stars indicating statistical significance.                                                                          |          |\n| `sort`                | If True, sort variables by `estimate` values in ascending order.                                                                                            |          |\n| `sortby`              | Name of column to sort by. Default is `estimate`.                                                                                                           |       |\n| `flush`               | If True (default), left-flush variable labels and annotations.                                                                                              |          |\n| `decimal_precision`   | Number of decimal places to print. (Default = 2)                                                                                                            |          |\n| `figsize`             | Tuple indicating core figure size. Default is (4, 8)                                                                                                        |          |\n| `xticks`              | List of xticklabels to print on x-axis.                                                                                                                     |       |\n| `ylabel`              | Y-label title.                                                                                                                                              |      |\n| `xlabel`              | X-label title.                                                                                                                                              |       |\n| `color_alt_rows`      | If True, shade out alternating rows in gray.                                                                                                                |          |\n| `preprocess`          | If True (default), preprocess the `dataframe` before plotting.                                                                                              |          |\n| `return_df`           | If True, returned the preprocessed `dataframe`.                                                                                                             |          |\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!------------------------ KNOWN ISSUES ------------------------\u003e\n## Known Issues[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#known-issues)\n\n* Variable labels coinciding with group variables may lead to unexpected formatting issues in the graph.\n* Left-flushing of annotations relies on the `monospace` font.\n* Plot may give strange behavior for few rows of data (six rows or fewer. [see this issue](https://github.com/LSYS/forestplot/issues/52))\n* Plot can get cluttered with too many variables/rows (~30 onwards) \n* Not tested with PyCharm (#80) nor Google Colab (#110).\n* Duplicated `varlabel` may lead to unexpected results (see #76, #81). `mplot` for grouped models could be useful for such cases (see #59, WIP).\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\u003c!----------------- BACKGROUND AND ADDITIONAL RESOURCES -----------------\u003e\n## Background and Additional Resources[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#background-and-additional-resources)\n\n**More about forest plots**\n\n[Forest plots](https://en.wikipedia.org/wiki/Forest_plot) have many aliases (h/t Chris Alexiuk). Other names include coefplots, coefficient plots, meta-analysis plots, dot-and-whisker plots, blobbograms, margins plots, regression plots, and ropeladder plots. \n\n[Forest plots](https://en.wikipedia.org/wiki/Forest_plot) in the medical and health sciences literature are plots that report results from different studies as a meta-analysis. Markers are centered on the estimated effect and horizontal lines running through each marker depicts the confidence intervals.\n\nThe simplest version of a forest plot has two columns: one for the variables/studies, and the second for the estimated coefficients and confidence intervals.\nThis layout is similar to coefficient plots ([coefplots](http://repec.sowi.unibe.ch/stata/coefplot/getting-started.html)) and is thus useful for more than meta-analyses.\n\n\u003cdetails\u003e\u003csummary\u003e\u003ci\u003eMore resources about forest plots\u003c/i\u003e\u003c/summary\u003e\u003cp\u003e\n\n* [[1]](https://doi.org/10.1038/s41433-021-01867-6) Chang, Y., Phillips, M.R., Guymer, R.H. et al. The 5 min meta-analysis: understanding how to read and interpret a forest plot. Eye 36, 673–675 (2022).\n* [[2]](https://doi.org/10.1136/bmj.322.7300.1479) Lewis S, Clarke M. Forest plots: trying to see the wood and the trees BMJ 2001; 322 :1479 \n\u003c/p\u003e\u003c/details\u003e\u003cp\u003e\u003c/p\u003e\n\n**More about this package**\n\nThe package is lightweight, built on `pandas`, `numpy`, and `matplotlib`.\n\nIt is slightly opinioniated in that the aesthetics of the plot inherits some of my sensibilities about what makes a nice figure.\nYou can however easily override most defaults for the look of the graph. This is possible via `**kwargs` in the `forestplot` API (see [Gallery and API options](#gallery-and-api-options)) and the `matplotlib` API.\n\n**Planned enhancements** include forest plots where each row can have multiple coefficients (e.g. from multiple models). \n\n\u003cdetails\u003e\u003csummary\u003e\u003ci\u003eRelated packages\u003c/i\u003e\u003c/summary\u003e\u003cp\u003e\n\n* [[1]](https://www.stata-journal.com/article.html?article=gr0059) [Stata] Jann, Ben (2014). Plotting regression coefficients and other estimates. The Stata Journal 14(4): 708-737. \n* [[2]](https://www.statsmodels.org/devel/examples/notebooks/generated/metaanalysis1.html) [Python] Meta-Analysis in statsmodels\n* [[3]](https://github.com/seafloor/forestplot) [Python] Matt Bracher-Smith's Forestplot\n* [[4]](https://github.com/fsolt/dotwhisker) [R] Solt, Frederick and Hu, Yue (2021) dotwhisker: Dot-and-Whisker Plots of Regression Results\n* [[5]](https://rpubs.com/mbounthavong/forest_plots_r) [R] Bounthavong, Mark (2021) Forest plots. RPubs by RStudio\n\u003c/p\u003e\u003c/details\u003e\u003cp\u003e\u003c/p\u003e\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!----------------------- CONTRIBUTING -----------------------\u003e\n## Contributing[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#contributing)\n\nContributions are welcome, and they are greatly appreciated!\n\n**Potential ways to contribute:**\n\n* Raise issues/bugs/questions\n* Write tests for missing coverage\n* Add features (see [examples notebook](https://nbviewer.org/github/LSYS/forestplot/blob/main/examples/readme-examples.ipynb) for a survey of  existing features)\n* Add example datasets with companion graphs\n* Add your graphs with companion code\n\n**Issues**\n\nPlease submit bugs, questions, or issues you encounter to the [GitHub Issue Tracker](https://github.com/lsys/forestplot/issues).\nFor bugs, please provide a minimal reproducible example demonstrating the problem (it may help me troubleshoot if I have a version of your data).\n\n**Pull Requests**\n\nPlease feel free to open an issue on the [Issue Tracker](https://github.com/lsys/forestplot/issues) if you'd like to discuss potential contributions via PRs.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsys%2Fforestplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flsys%2Fforestplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsys%2Fforestplot/lists"}