Metadata-Version: 2.1
Name: dufte
Version: 0.2.24
Summary: Clean matplotlib plots
Home-page: https://github.com/nschloe/dufte
Author: Nico Schlömer
Author-email: nico.schloemer@gmail.com
License: GPL-3.0-or-later
Project-URL: Code, https://github.com/nschloe/dufte
Project-URL: Issues, https://github.com/nschloe/dufte/issues
Project-URL: Funding, https://github.com/sponsors/nschloe
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Matplotlib
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Utilities
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: matplotlib
Requires-Dist: numpy

<p align="center">
  <a href="https://github.com/nschloe/dufte"><img alt="dufte-logo" src="https://nschloe.github.io/dufte/logo.svg" width="40%"></a>
  <p align="center"><a href="https://en.wikipedia.org/wiki/Berlin_German">Da kiekste, wa?</a></p>
</p>

[![PyPi Version](https://img.shields.io/pypi/v/dufte.svg?style=flat-square)](https://pypi.org/project/dufte/)
[![Anaconda Cloud](https://anaconda.org/conda-forge/dufte/badges/version.svg?=style=flat-square)](https://anaconda.org/conda-forge/dufte/)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/dufte.svg?style=flat-square)](https://pypi.org/project/dufte/)
[![GitHub stars](https://img.shields.io/github/stars/nschloe/dufte.svg?logo=github&label=Stars&logoColor=white&style=flat-square)](https://github.com/nschloe/dufte)
[![PyPi downloads](https://img.shields.io/pypi/dm/dufte.svg?style=flat-square)](https://pypistats.org/packages/dufte)

[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/dufte/ci?style=flat-square)](https://github.com/nschloe/dufte/actions?query=workflow%3Aci)
[![codecov](https://img.shields.io/codecov/c/github/nschloe/dufte.svg?style=flat-square)](https://codecov.io/gh/nschloe/dufte)
[![LGTM](https://img.shields.io/lgtm/grade/python/github/nschloe/dufte.svg?style=flat-square)](https://lgtm.com/projects/g/nschloe/dufte)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)

This package creates clean and beautiful plots that work on light and dark backgrounds.
Inspired by the work of [Edward Tufte](https://en.wikipedia.org/wiki/Edward_Tufte).

<img src="https://nschloe.github.io/dufte/ex1.svg"> |  <img src="https://nschloe.github.io/dufte/bar.svg">
:----:|:----:|

To use, simply select the `dufte` style. Check out `dufte.legend()` and
`dufte.ylabel()` for more duftness.
```python
import matplotlib.pyplot as plt
import dufte
import numpy as np

plt.style.use(dufte.style)

rng = np.random.default_rng(0)

x0 = np.linspace(0.0, 3.0, 100)
y0 = x0 / (x0 + 1)
y0 += 0.1 * rng.random(len(y0))
plt.plot(x0, y0, label="no balacing")

x1 = np.linspace(0.0, 3.0, 100)
y1 = 1.5 * x1 / (x1 + 1)
y1 += 0.1 * rng.random(len(y1))
plt.plot(x1, y1, label="CRV-27")

x2 = np.linspace(0.0, 3.0, 100)
y2 = 1.6 * x2 / (x2 + 1)
y2 += 0.1 * rng.random(len(y2))
plt.plot(x2, y2, label="CRV-27*")

dufte.ylabel("ylabel")
dufte.legend()

plt.show()
```
The bar plot is created with `dufte.style_bar` here and `dufte.show_bar_values()`.
Note the use of `context` instead of `style.use()`; both are appropriate.
```python
import matplotlib.pyplot as plt
import dufte


with plt.style.context(dufte.style_bar):
    labels = ["Australia", "Brazil", "China", "Germany", "Mexico", "United\nStates"]
    vals = [21.65, 24.5, 6.95, 8.40, 21.00, 8.55]
    xpos = range(len(vals))
    plt.bar(xpos, vals)
    plt.xticks(xpos, labels)
    dufte.show_bar_values("{:.2f}")
    plt.title("average temperature [°C]")
    plt.show()
```

Further reading:

 * [Remove to improve: data-ink ratio](https://www.darkhorseanalytics.com/blog/data-looks-better-naked)
   <img src="https://nschloe.github.io/dufte/data-ink.webp">
 * [Remove to improve: Line Graph Edition](https://youtu.be/bDbJBWvonVI)
 * [Show the Data - Maximize the Data Ink Ratio](https://youtu.be/pCp0a5_YIWE)
 * [Randal S. Olson's blog entry](http://www.randalolson.com/2014/06/28/how-to-make-beautiful-data-visualizations-in-python-with-matplotlib/)
 * [prettyplotlib](https://github.com/olgabot/prettyplotlib)
 * [Wikipedia: Chartjunk](https://en.wikipedia.org/wiki/Chartjunk)

Projects using dufte:

 * [perfplot](https://github.com/nschloe/perfplot)
 * [stargraph](https://github.com/nschloe/stargraph)


### Background
[![xdoc](https://img.shields.io/badge/Rendered%20with-xdoc-f2eecb?style=flat-square)](https://chrome.google.com/webstore/detail/xdoc/anidddebgkllnnnnjfkmjcaallemhjee)

The position $`x_i`$ of the line annotations is computed as the solution of a
non-negative least-squares problem
```math
\begin{align}
\frac{1}{2}\sum_i (x_i - t_i)^2 \to \min_x,\\
(x_i - x_j)^2 \ge a^2 \quad \forall i,j.
\end{align}
```
where $`a`$ is the minimum distance between two entries and $`t_i`$ is the target
position.


### Testing

To run the dufte unit tests, check out this repository and type
```
pytest
```

### License
This software is published under the [GPLv3
license](https://www.gnu.org/licenses/gpl-3.0.en.html).


