Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #5 from nschloe/plotstyle
Browse files Browse the repository at this point in the history
use plotstyle
  • Loading branch information
nschloe authored Apr 30, 2020
2 parents 6a73de5 + 0a7aadb commit aee6f6a
Show file tree
Hide file tree
Showing 15 changed files with 237 additions and 290 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Test with pytest
run: |
pip install pytest pytest-cov
pytest --cov cleanplotlib
pytest --cov dufte
# No codecov until
# https://github.com/codecov/codecov-action/issues/43
# is solved. :(
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cleanplotlib Code of Conduct
# dufte Code of Conduct

## Our Pledge

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# cleanplotlib contributing guidelines
# dufte contributing guidelines

The cleanplotlib community appreciates your contributions via issues and
The dufte community appreciates your contributions via issues and
pull requests. Note that the [code of conduct](CODE_OF_CONDUCT.md)
applies to all interactions with the cleanplotlib project, including
applies to all interactions with the dufte project, including
issues and pull requests.

When submitting pull requests, please follow the style guidelines of
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ upload:
tag:
@if [ "$(shell git rev-parse --abbrev-ref HEAD)" != "master" ]; then exit 1; fi
# Always create a github "release"; this automatically creates a Git tag, too.
curl -H "Authorization: token `cat $(HOME)/.github-access-token`" -d '{"tag_name": "v$(VERSION)"}' https://api.github.com/repos/nschloe/cleanplotlib/releases
curl -H "Authorization: token `cat $(HOME)/.github-access-token`" -d '{"tag_name": "v$(VERSION)"}' https://api.github.com/repos/nschloe/dufte/releases

publish: tag upload

Expand Down
53 changes: 23 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,51 @@
# cleanplotlib
<p align="center">
<a href="https://github.com/nschloe/dufte"><img alt="dufte-logo" src="https://nschloe.github.io/dufte/logo.svg" width="60%"></a>
<p align="center">[Tufte](https://en.wikipedia.org/wiki/Edward_Tufte)-style plots [from Berlin](https://www.linguee.com/german-english/translation/dufte.html).</p>
</p>

[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/cleanplotlib/ci?style=flat-square)](https://github.com/nschloe/cleanplotlib/actions?query=workflow%3Aci)
[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/dufte/ci?style=flat-square)](https://github.com/nschloe/dufte/actions?query=workflow%3Aci)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/cleanplotlib.svg?style=flat-square)](https://pypi.org/pypi/cleanplotlib/)
[![PyPi Version](https://img.shields.io/pypi/v/cleanplotlib.svg?style=flat-square)](https://pypi.org/project/cleanplotlib)
[![GitHub stars](https://img.shields.io/github/stars/nschloe/cleanplotlib.svg?logo=github&label=Stars&logoColor=white&style=flat-square)](https://github.com/nschloe/cleanplotlib)
[![PyPi downloads](https://img.shields.io/pypi/dm/cleanplotlib.svg?style=flat-square)](https://pypistats.org/packages/cleanplotlib)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/dufte.svg?style=flat-square)](https://pypi.org/pypi/dufte/)
[![PyPi Version](https://img.shields.io/pypi/v/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)

This package creates clean and beautiful plots like

<p align="center">
<img alt="dmsh" src="https://nschloe.github.io/cleanplotlib/ex1.svg" width="70%">
<img src="https://nschloe.github.io/dufte/ex1.svg" width="70%">
</p>

Simply select the `"dufte"` style and, if desired, call `dufte.legend()` to get
line annotations on the right.

```python
import cleanplotlib as cpl
import matplotlib.pyplot as plt
import dufte
import numpy

plt.style.use("dufte")

numpy.random.seed(0)

x0 = numpy.linspace(0.0, 3.0, 100)
y0 = x0 / (x0 + 1)
y0 += 0.1 * numpy.random.rand(len(y0))
cpl.plot(x0, y0, "no balacing")
plt.plot(x0, y0, "no balacing")

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

x2 = numpy.linspace(0.0, 3.0, 100)
y2 = 1.6 * x2 / (x2 + 1)
y2 += 0.1 * numpy.random.rand(len(y2))
cpl.plot(x2, y2, "CRV-27*")

cpl.show()
# cpl.savefig("ex1.svg", transparent=True, bbox_inches="tight")
```
If the plot labels get crowded, `cpl.multiplot` arranged them for you:
```python
import cleanplotlib as cpl
import numpy
numpy.random.seed(0)

x = numpy.linspace(0.0, 3.0, 100)
y0 = x / (x + 1)
y1 = 1.01 * x / (x + 1)
y2 = 1.03 * x / (x + 1)
plt.plot(x2, y2, "CRV-27*")

cpl.multiplot(
[x, x, x], [y0, y1, y2], ["no balancing", "CRV27", "CRV27*"]
)
dufte.legend()

cpl.show()
plt.show()
```
Further reading:

Expand All @@ -63,7 +56,7 @@ Further reading:

### Testing

To run the cleanplotlib unit tests, check out this repository and type
To run the dufte unit tests, check out this repository and type
```
pytest
```
Expand Down
4 changes: 0 additions & 4 deletions cleanplotlib/__init__.py

This file was deleted.

188 changes: 0 additions & 188 deletions cleanplotlib/main.py

This file was deleted.

2 changes: 1 addition & 1 deletion cleanplotlib/__about__.py → dufte/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
import importlib_metadata as metadata

try:
__version__ = metadata.version("cleanplotlib")
__version__ = metadata.version("dufte")
except Exception:
__version__ = "unknown"
4 changes: 4 additions & 0 deletions dufte/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .__about__ import __version__
from .main import legend

__all__ = ["__version__", "legend"]
33 changes: 33 additions & 0 deletions dufte/dufte.mplstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
font.size: 14

# dufte is used via perfplot on stackoverflow which has a light (#fffff) and a
# dark (#2d2d2d) variant. The midpoint, #969696, should be well readable on both. (And
# stays in the background, like a grid should.)
text.color : 969696

axes.labelcolor: 969696

axes.spines.left : False
axes.spines.bottom : False
axes.spines.top : False
axes.spines.right : False

ytick.left : False
ytick.right: False
ytick.color: 969696

xtick.minor.visible: False
xtick.color: 969696

axes.grid: True
axes.grid.axis: y
grid.color : 969696
grid.linewidth : 0.5
# grid.linestyle : --
# grid.dashes : 10, 10

# mpl uses category10 by default, we use cat20,
# <https://github.com/d3/d3-3.x-api-reference/blob/master/Ordinal-Scales.md#category20>,
# which basically adds one pale color version of each color in cat10.
# Change the order such that the first 10 are cat10.
axes.prop_cycle : cycler("color", ["1f77b4", "ff7f0e", "2ca02c", "d62728", "9467bd", "8c564b", "e377c2", "7f7f7f", "bcbd22", "17becf", "aec7e8", "ffbb78", "98df8a", "ff9896", "c5b0d5", "c49c94", "f7b6d2", "c7c7c7", "dbdb8d", "9edae5"])
Loading

0 comments on commit aee6f6a

Please sign in to comment.