Skip to content

Commit

Permalink
Merge pull request #12 from nschloe/readme
Browse files Browse the repository at this point in the history
readme
  • Loading branch information
nschloe committed Dec 2, 2021
2 parents 2096919 + 3a5c1c1 commit 2868162
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ import mplx

See below for what mplx can do.

### Clean line plots
### Clean line plots (dufte)

<a href="tests/dufte_comparison.py">
<table width="100%">
<tr>
<td width="50%"><img src="https://nschloe.github.io/mplx/ex1-mpl.svg"/></td>
<td width="50%"><img src="https://nschloe.github.io/mplx/ex1-dufte.svg"/></td>
<td width="33%"><img src="https://nschloe.github.io/mplx/ex1-mpl.svg"/></td>
<td width="33%"><img src="https://nschloe.github.io/mplx/ex1-dufte.svg"/></td>
<td width="33%"><img src="https://nschloe.github.io/mplx/ex1-dufte-dracula.svg"/></td>
</tr>
<tr>
<td>matplotlib</td>
Expand All @@ -42,11 +43,14 @@ See below for what mplx can do.
<code>mplx.ylabel_top</code>,
<code>mplx.line_labels</code>
</td>
<td>
<code>mplx.styles.dracula | mplx.styles.dufte</code>
</td>
</tr>
</table>
</a>

The right plot is created with
The middle plot is created with

```python
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -76,6 +80,16 @@ The three mplx ingredients are:
- `mplx.ylabel_top`: Rotate and move the the y-label
- `mplx.line_labels`: Show line labels to the right, with the line color

You can also combine dufte with any other style (see below) with

<!--pytest-codeblocks:skip-->

```python
plt.style.use(mplx.styles.dracula | mplx.styles.dufte)
```

(This uses the Python 3.10 dict merge operator `|`. If you're using an older Python version, you have to use, e.g., `{**x, **y}`.)

Further reading and other styles:

- [Remove to improve: data-ink ratio](https://www.darkhorseanalytics.com/blog/data-looks-better-naked)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = mplx
version = 0.2.0
version = 0.2.1
author = Nico Schlömer
author_email = nico.schloemer@gmail.com
description = Extensions for Matplotlib
Expand Down
14 changes: 12 additions & 2 deletions tests/dufte_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def line():
plt.xlabel("distance [m]")
plt.ylabel("voltage [V]")
plt.legend()
plt.savefig("ex1-mpl.svg", transparent=True, bbox_inches="tight")
plt.savefig("ex1-mpl.svg", bbox_inches="tight")
plt.close()

# dufte
Expand All @@ -29,7 +29,17 @@ def line():
plt.xlabel("distance [m]")
mplx.ylabel_top("voltage [V]")
mplx.line_labels()
plt.savefig("ex1-dufte.svg", transparent=True, bbox_inches="tight")
plt.savefig("ex1-dufte.svg", bbox_inches="tight")
plt.close()

# dufte
with plt.style.context(mplx.styles.dracula | mplx.styles.dufte):
for yy, label in zip(y, labels):
plt.plot(x0, yy, label=label)
plt.xlabel("distance [m]")
mplx.ylabel_top("voltage [V]")
mplx.line_labels()
plt.savefig("ex1-dufte-dracula.svg", bbox_inches="tight")
plt.close()


Expand Down

0 comments on commit 2868162

Please sign in to comment.