Skip to main content

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 *_wob style 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.9.tar.gz (218.9 kB view details)

Uploaded Source

File details

Details for the file aesthetic-0.9.tar.gz.

File metadata

  • Download URL: aesthetic-0.9.tar.gz
  • Upload date:
  • Size: 218.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for aesthetic-0.9.tar.gz
Algorithm Hash digest
SHA256 de93e6045ca41b20ae92e16aaedba8077fb922ceb9c2f6f236f98f4ccdf67cc9
MD5 ef5d04f8245b9e3ed0482b28a3287d26
BLAKE2b-256 8f26c2de65e77b4c55ef480b9e8d57cbe1309dae3dd0becd41f5859d98bd90ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page