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 #37 from nschloe/distance-label-lines
Browse files Browse the repository at this point in the history
Distance label-lines
  • Loading branch information
nschloe authored Jul 16, 2021
2 parents 3614bad + 97cb88e commit 3435436
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,12 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
with:
python-version: "3.x"
- uses: actions/checkout@v2
- name: Lint with flake8
run: |
pip install flake8
flake8 .
- name: Lint with black
run: |
pip install black
black --check .
- name: Check out repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Run pre-commit
uses: pre-commit/[email protected]

build:
runs-on: ubuntu-latest
Expand Down
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.9.1
hooks:
- id: isort

- repo: https://github.com/python/black
rev: 21.6b0
hooks:
- id: black
language_version: python3

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</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/pypi/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)
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = dufte
version = 0.2.20
version = 0.2.21
author = Nico Schlömer
author_email = [email protected]
description = Clean matplotlib plots
Expand All @@ -14,6 +14,7 @@ long_description_content_type = text/markdown
license = GPL-3.0-or-later
classifiers =
Development Status :: 4 - Beta
Framework :: Matplotlib
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Operating System :: OS Independent
Programming Language :: Python
Expand Down
5 changes: 4 additions & 1 deletion src/dufte/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ def legend(ax=None, min_label_distance="auto", alpha: float = 1.0):
xlim0, xlim1 = ax.get_xlim()
for label, t, color in zip(labels, targets, colors):
plt.text(
xlim1 + (xlim1 - xlim0) / 100,
# Leave the labels some space to breathe. If they are too close to the
# lines, they can get visually merged.
# <https://twitter.com/EdwardTufte/status/1416035189843714050>
xlim1 + (xlim1 - xlim0) / 100 * 3,
t,
label,
verticalalignment="center",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def test_plot(filename, light: bool, noise, offsets):
y0 += noise * np.random.rand(len(y0))
plt.plot(x0, y0, label=label)

plt.xlabel("x label")
plt.ylabel("y label")
plt.xlabel("distance [m]")
dufte.ylabel("voltage [V]")
# plt.title("title")
dufte.legend()

Expand Down

0 comments on commit 3435436

Please sign in to comment.