Skip to content

Commit 30ee8d0

Browse files
authored
Patch (#55)
* Fix spacing issue at top of plot (fixes #48, #47) * Create notebook for some simple regression tests (closes #49) * Tidy imports using isort (closes #50) * Allowed thresholds and symbols for p-values to be passedthrough (fixes #51) * Fix different heigh and fontsize for confidence interval and p-value labels (fixes #53) * Update docs for RTD (closes #54) * Freeze matplotlib-inline dependency in setup.py (closes #56)
1 parent 8641fe4 commit 30ee8d0

31 files changed

Lines changed: 1331 additions & 207 deletions

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ lint:
2424
mypy $(SRC_FILES) --ignore-missing-imports
2525
python -m pyflakes tests/*.py $(SRC_FILES)
2626
python -m pyflakes setup.py
27+
isort --profile black $(BLACK_OPTS) .
2728
black forestplot/*.py $(BLACK_OPTS)
2829
black forestplot/*.py $(BLACK_OPTS)
2930
black tests/*.py $(BLACK_OPTS)
3031
black setup.py $(BLACK_OPTS)
3132

33+
.PHONY: docstring
34+
docstring: # Check docstrings using pydocstyle
35+
pydocstyle --convention numpy
36+
3237
.PHONY: prepack
3338
prepack: # Prepare packaging for PyPi
3439
prepack:

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div id="top"></div>
22
<h1 align="center" >
3-
<strong>Forestplot</strong>
3+
Forestplot
44
</h1>
55
<p align="center">
66
<a href="https://pypi.org/project/forestplot">
@@ -13,24 +13,24 @@
1313
<p align="center"><img width="100%" src="https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/main.png"></p>
1414

1515
-----------------------------------------------------------
16-
1716
This 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.
1817
Additional options allow easy addition of columns in the `dataframe` as annotations in the plot.
1918

2019
<!---------------------- Project shields ---------------------->
2120

2221
| | |
2322
| --- | --- |
24-
| Release | [![PyPI](https://img.shields.io/pypi/v/forestplot?color=blue&label=PyPI&logo=pypi&logoColor=white)](https://pypi.org/project/forestplot/) ![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/forestplot?logo=conda-forge&logoColor=white) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/lsys/forestplot?color=blue&label=Latest%20release)](https://github.com/LSYS/forestplot/releases) |
23+
| Release | [![PyPI](https://img.shields.io/pypi/v/forestplot?color=blue&label=PyPI&logo=pypi&logoColor=white)](https://pypi.org/project/forestplot/) [![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/forestplot?logo=conda-forge&logoColor=white)](https://anaconda.org/conda-forge/forestplot) [![GitHub release (latest by date)](https://img.shields.io/github/v/release/lsys/forestplot?color=blue&label=Latest%20release)](https://github.com/LSYS/forestplot/releases) |
2524
| 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) |
2625
| Coverage | [![Codecov](https://img.shields.io/codecov/c/github/lsys/forestplot?logo=codecov&logoColor=white&label=codecov)](https://app.codecov.io/gh/LSYS/forestplot) |
2726
| Python | [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/forestplot?label=Python%203.6%2B&logo=python&logoColor=white)](https://pypi.org/project/forestplot/) |
2827
| Docs | [![Read the Docs (version)](https://img.shields.io/readthedocs/forestplot/stable?label=docs&logo=readthedocs&logoColor=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)|
29-
| Meta | ![GitHub](https://img.shields.io/github/license/lsys/forestplot?color=purple&label=License) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/LSYS/forestplot.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/LSYS/forestplot/context:python) [![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) |
28+
| Meta | [![GitHub](https://img.shields.io/github/license/lsys/forestplot?color=purple&label=License)](https://choosealicense.com/licenses/mit/) [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=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) |
3029
| Binder| [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/lsys/forestplot/main?labpath=examples%2Freadme-examples.ipynb) |
3130

3231
<!---------------------- TABLE OF CONTENT ---------------------->
33-
<details open><summary><b>Table of Contents</b></summary><p>
32+
# Table of Contents[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#table-of-contents)
33+
<details open><summary><b>show/hide</b></summary><p>
3434

3535
> - [Installation](#installation)
3636
> - [Quick Start](#quick-start)
@@ -51,7 +51,7 @@ pip install forestplot
5151
```
5252

5353
Install from conda-forge<br>
54-
![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/forestplot?logo=conda-forge&logoColor=white)
54+
[![Conda (channel only)](https://img.shields.io/conda/vn/conda-forge/forestplot?logo=conda-forge&logoColor=white)](https://anaconda.org/conda-forge/forestplot)
5555
```bash
5656
conda install forestplot
5757
```
@@ -78,7 +78,7 @@ make test
7878

7979

8080
<!------------------------- QUICK START ------------------------->
81-
## Quick start[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#quick-start)
81+
## Quick Start[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#quick-start)
8282

8383
```python
8484
import forestplot as fp
@@ -119,7 +119,7 @@ fp.forestplot(df, # the dataframe with results data
119119
ll="ll", hl="hl", # columns containing conf. int. lower and higher limits
120120
varlabel="label", # column containing variable label
121121
ylabel="Confidence interval", # y-label title
122-
xlabel="Pearson correlation" # x-label title
122+
xlabel="Pearson correlation", # x-label title
123123
)
124124
```
125125
<p align="left"><img width="55%" src="https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/vanilla.png"></p>
@@ -131,8 +131,7 @@ plt.savefig("plot.png", bbox_inches="tight")
131131
<p align="right">(<a href="#top">back to top</a>)</p>
132132

133133
<!------------------ EXAMPLES of CUSTOMIZATIONS ------------------>
134-
## Some examples with customizations[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#examples-with-customizations)
135-
134+
## Some Examples With Customizations[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#examples-with-customizations)
136135

137136
1. Add variable groupings, add group order, and sort by estimate size.
138137
```python
@@ -145,10 +144,10 @@ fp.forestplot(df, # the dataframe with results data
145144
# group ordering
146145
group_order=["labor factors", "occupation", "age", "health factors",
147146
"family factors", "area of residence", "other factors"],
148-
sort=True # sort in ascending order (sorts within group if group is specified)
147+
sort=True, # sort in ascending order (sorts within group if group is specified)
149148
)
150149
```
151-
<p align="left"><img width="65%" src="https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/group-grouporder-sort.png"></p>
150+
<p align="left"><img width="75%" src="https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/group-grouporder-sort.png"></p>
152151

153152
2. Add p-values on the right and color alternate rows gray
154153
```python
@@ -169,7 +168,7 @@ fp.forestplot(df, # the dataframe with results data
169168
)
170169
```
171170

172-
<p align="left"><img width="70%" src="https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/group-grouporder-pvalue-sort-colorrows.png"></p>
171+
<p align="left"><img width="80%" src="https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/group-grouporder-pvalue-sort-colorrows.png"></p>
173172

174173

175174
3. Customize annotations and make it a table
@@ -189,7 +188,7 @@ fp.forestplot(df, # the dataframe with results data
189188
)
190189
```
191190

192-
<p align="left"><img width="75%" src="https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/leftannote-rightannote-table.png"></p>
191+
<p align="left"><img width="85%" src="https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/leftannote-rightannote-table.png"></p>
193192

194193
4. Strip down all bells and whistle
195194
```python
@@ -233,7 +232,7 @@ fp.forestplot(df, # the dataframe with results data
233232
}
234233
)
235234
```
236-
<p align="left"><img width="70%" src="https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/main.png"></p>
235+
<p align="left"><img width="80%" src="https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/main.png"></p>
237236

238237
<details><summary><i>Annotations arguments allowed include:</i></summary>
239238

@@ -307,8 +306,10 @@ More fined-grained control for base plot options (eg font sizes, marker colors)
307306

308307
<!------------------------ KNOWN ISSUES ------------------------>
309308
## Known Issues[![](https://raw.githubusercontent.com/LSYS/forestplot/main/docs/images/pin.svg)](#known-issues)
309+
310310
* Variable labels coinciding with group variables may lead to unexpected formatting issues in the graph.
311311
* Left-flushing of annotations relies on the `monospace` font.
312+
* Plot may give strange behavior for few rows of data (six rows or fewer. [see this issue](https://github.com/LSYS/forestplot/issues/52))
312313
* Plot can get cluttered with too many variables/rows (~30 onwards)
313314
<p align="right">(<a href="#top">back to top</a>)</p>
314315

codecov.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ coverage:
55
target: auto
66
# adjust accordingly based on how flaky your tests are
77
# this allows a 10% drop from the previous base commit coverage
8-
threshold: 50% # Relax my coverage target, because I have flaky tests
8+
threshold: 10% # Relax my coverage target, because I have flaky tests
9+
patch: off

docs/README.rst

Whitespace-only changes.

docs/assets/issue52-table-does-not-work-6rows-or-fewer.ipynb

Lines changed: 328 additions & 0 deletions
Large diffs are not rendered by default.

docs/conf.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Config file for Sphinx."""
12
# Configuration file for the Sphinx documentation builder.
23
#
34
# This file only contains a selection of the most common options. For a full
@@ -17,8 +18,8 @@
1718

1819
# -- Project information -----------------------------------------------------
1920

20-
project = 'pyForestplot'
21-
copyright = '2022, Lucas Shen'
21+
project = 'Forestplot'
22+
copyright = '2023, Lucas Shen'
2223
author = 'Lucas Shen'
2324

2425
# The full version, including alpha/beta/rc tags
@@ -33,7 +34,7 @@
3334
extensions = [
3435
'myst_parser'
3536
]
36-
37+
myst_heading_anchors = 2
3738
# Add any paths that contain templates here, relative to this directory.
3839
templates_path = ['_templates']
3940

@@ -49,7 +50,16 @@
4950
# a list of builtin themes.
5051
#
5152
html_theme = 'furo'
52-
53+
html_sidebars = {
54+
"**": [
55+
"sidebar/scroll-start.html",
56+
"sidebar/brand.html",
57+
"sidebar/search.html",
58+
"sidebar/navigation.html",
59+
"sidebar/ethical-ads.html",
60+
"sidebar/scroll-end.html",
61+
]
62+
}
5363
# Add any paths that contain custom static files (such as style sheets) here,
5464
# relative to this directory. They are copied after the builtin static files,
5565
# so a file named "default.css" will overwrite the builtin "default.css".
-557 Bytes
Loading
-158 Bytes
Loading
524 Bytes
Loading

docs/images/main.png

768 Bytes
Loading

0 commit comments

Comments
 (0)