Metadata-Version: 2.4
Name: probscale
Version: 0.2.6.dev0
Summary: mpl-probscale: Probability scales for matplotlib
Author-email: "Paul Hobson (Herrera Environmental Consultants)" <phobson@herrerainc.com>
License: Copyright (c) 2015, Paul Hobson
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of mpl-probscale nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
        
Project-URL: Homepage, https://github.com/matplotlib/mpl-probscale
Project-URL: Download, https://github.com/matplotlib/mpl-probscale/archive/master.zip
Keywords: matplotlib,probability,scale,plotting
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: AUTHORS.rst
Requires-Dist: numpy
Requires-Dist: matplotlib
Dynamic: license-file

# mpl-probscale

Real probability scales for matplotlib

| CI | Badge |
| ----- | ----- |
| Tests | ![Tests](https://github.com/matplotlib/mpl-probscale/actions/workflows/python-runtests-all.yml/badge.svg) |
| Formatting and Types | ![Ruff/Ty](https://github.com/matplotlib/mpl-probscale/actions/workflows/ruff_ty.yml/badge.svg) |
| Linting | ![Linter](https://github.com/matplotlib/mpl-probscale/actions/workflows/python-runlinter.yml/badge.svg) |
| Docs | ![Docs](https://github.com/matplotlib/mpl-probscale/actions/workflows/docs.yml/badge.svg) |


[Sphinx Docs](http://matplotlib.org/mpl-probscale/)

## Installation

### Official releases

Official releases are available through the conda-forge channel or pip

`conda install mpl-probscale --channel=conda-forge`

`pip install probscale`

### Development builds

This is a pure-python package, so building from source is easy on all platforms:

```shell
git clone git@github.com:matplotlib/mpl-probscale.git
cd mpl-probscale
pip install -e .
```

## Quick start

Simply importing `probscale` lets you use probability scales in your matplotlib figures:

```python
from matplotlib import pyplot
from scipy import stats
import probscale  # nothing else needed

beta = stats.beta(a=3, b=4)
weibull = stats.weibull_min(c=5)
scales = [
    {"scale": {"value": "linear"}, "label": "Linear (built-in)"},
    {"scale": {"value": "log", "base": 10}, "label": "Log. Base 10 (built-in)"},
    {"scale": {"value": "log", "base": 2}, "label": "Log. Base 2 (built-in)"},
    {"scale": {"value": "logit"}, "label": "Logit (built-in)"},
    {"scale": {"value": "prob"}, "label": "Standard Normal Probability (this package)"},
    {
        "scale": {"value": "prob", "dist": weibull},
        "label": "Weibull probability scale, c=5 (this package)",
    },
    {
        "scale": {"value": "prob", "dist": beta},
        "label": "Beta probability scale, α=3 & β=4 (this package)",
    },
]

N = len(scales)
fig, axes = pyplot.subplots(nrows=N, figsize=(9, N - 1), constrained_layout=True)
for scale, ax in zip(scales, axes.flat):
    ax.set_xscale(**scale["scale"])
    ax.text(0.0, 0.1, scale["label"] + " →", transform=ax.transAxes)
    ax.set_xlim(left=0.5, right=99.5)
    ax.set_yticks([])
    ax.spines.left.set_visible(False)
    ax.spines.right.set_visible(False)
    ax.spines.top.set_visible(False)

outpath = Path(__file__).parent.joinpath("../img/example.png").resolve()
fig.savefig(outpath, dpi=300)
```

![Alt text](https://raw.githubusercontent.com/matplotlib/mpl-probscale/main/docs/img/example.png "Example axes")

## Testing

Testing is generally done via ``pytest``.

```shell
python -m pytest --mpl --doctest-glob="probscale/*.py"
```

### Image comparison tests

Run the image comparison tests with:

```shell
uv run pytest --mpl --mpl-generate-summary=html --mpl-results-path=figcomp
```

That will generate a `figcomp` folder with the results and an HTML file you can open up to view all of the failures.

If the failures are all reasonable, general new baseline images for those tests with:

```shell
uv run pytest --mpl-generate-path=baseline
```

...and copy everything over to the right directory.
