a e s t h e t i c
Project description
a e s t h e t i c
Luke's matplotlib style sheets. Remixed from John Garrett's SciencePlots.
Preferences:
- Avoid constantly repeating matplotlib calls to prettify plots.
- Default font: Arial (not DejaVu Sans, which many systems don't have installed by default)
- Don't draw right and top axis spines unless they provide function.
- White on black reduces eye strain; make generating white on black figures easy by using
*_wobstyle sheets.
install
...via pip: pip install aesthetic
...via local clone: git clone git@github.com:lgbouma/aesthetic.git; cd aesthetic; pip install -e .
examples
for plot styles, see the test driver. the general syntax follows:
from aesthetic import set_style
set_style("clean")
set_style("clean_wob")
set_style("science")
set_style("science_wob")
So if you wanted to make four different versions of the same plot with responsive colors:
from aesthetic.plot import set_style
import numpy as np, matplotlib.pyplot as plt, matplotlib as mpl
def make_plot(style):
x = np.linspace(0,10,1000)
y = (x/100)**3 + 5*np.sin(x)
_x, _y = np.arange(2, 8, 0.5), np.arange(2, 8, 0.5)
fig, ax = plt.subplots(figsize=(3,2.5))
cs = [None]*3 if '_wob' not in style else ['cyan','lime','yellow']
ax.plot(x, y, label=f'style: {style}', color=cs[0])
ax.plot(x, y+3, color=cs[1])
ax.plot(x, y+6, color=cs[2])
_yerr = np.abs(np.random.normal(2, 1, _x.size))
c = 'k' if '_wob' not in style else 'w'
ax.errorbar(_x, _y, yerr=_yerr, marker='o', elinewidth=0.5, lw=0, c=c, markersize=2)
ax.update({ 'xlabel': r'x [units]', 'ylabel': r'y [units]' })
ax.legend(fontsize='small')
return fig
if __name__ == '__main__':
styles = ['clean', 'science', 'clean_wob', 'science_wob']
for style in styles:
set_style(style)
fig = make_plot(style)
fig.savefig(f'../results/plot_{style}.png', bbox_inches='tight', dpi=400)
mpl.rc_file_defaults()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aesthetic-0.8.tar.gz
(230.4 kB
view details)
File details
Details for the file aesthetic-0.8.tar.gz.
File metadata
- Download URL: aesthetic-0.8.tar.gz
- Upload date:
- Size: 230.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f4a63b1ff84983fd3eb3b160eb2a1ef5fe7f006f7d9cdd5062beabc701966df
|
|
| MD5 |
144a63249fefb56e6ec499c3c58cbf3c
|
|
| BLAKE2b-256 |
7a010132705fb67a2d6537bf48be9024b7cedaff35fcea3ee91858557685e642
|