aesthetic 0.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aesthetic/__init__.py +23 -0
- aesthetic/paper.py +50 -0
- aesthetic/plot.py +56 -0
- aesthetic/styles/__init__.py +0 -0
- aesthetic/styles/clean.mplstyle +56 -0
- aesthetic/styles/clean_wob.mplstyle +71 -0
- aesthetic/styles/grid.mplstyle +22 -0
- aesthetic/styles/notebook.mplstyle +41 -0
- aesthetic/styles/scatter.mplstyle +15 -0
- aesthetic/styles/science.mplstyle +66 -0
- aesthetic/styles/science_wob.mplstyle +68 -0
- aesthetic-0.10.dist-info/METADATA +105 -0
- aesthetic-0.10.dist-info/RECORD +16 -0
- aesthetic-0.10.dist-info/WHEEL +5 -0
- aesthetic-0.10.dist-info/licenses/LICENSE +21 -0
- aesthetic-0.10.dist-info/top_level.txt +1 -0
aesthetic/__init__.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Public API for aesthetic.
|
|
2
|
+
|
|
3
|
+
Delay heavy imports so that packaging hooks can import this module without
|
|
4
|
+
requiring matplotlib/numpy to already be installed.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
__all__ = ["set_style", "savefig"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def set_style(*args, **kwargs):
|
|
13
|
+
"""Proxy to ``plot.set_style`` with a lazy import."""
|
|
14
|
+
from .plot import set_style as _set_style
|
|
15
|
+
|
|
16
|
+
return _set_style(*args, **kwargs)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def savefig(*args, **kwargs):
|
|
20
|
+
"""Proxy to ``plot.savefig`` with a lazy import."""
|
|
21
|
+
from .plot import savefig as _savefig
|
|
22
|
+
|
|
23
|
+
return _savefig(*args, **kwargs)
|
aesthetic/paper.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from collections import OrderedDict
|
|
2
|
+
|
|
3
|
+
def abbreviate_the_bibliography(input_bib, output_bib):
|
|
4
|
+
"""
|
|
5
|
+
Zotero generates long journal names. Abbreviate them in bulk to conform to
|
|
6
|
+
the AAS style guide, and to have a shorter bibliography.
|
|
7
|
+
|
|
8
|
+
Args:
|
|
9
|
+
input_bib (str): path with long names, e.g., '/foo/bar/bibliography.bib'
|
|
10
|
+
output bib (str): path to be created, e.g., '/foo/bar/abbrev.bib'
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
mdict = OrderedDict({})
|
|
14
|
+
|
|
15
|
+
mdict['The Astrophysical Journal Letters'] = r'\apjl'
|
|
16
|
+
mdict['The Astrophysical Journal Supplement Series'] = r'\apjs'
|
|
17
|
+
mdict['The Astronomical Journal'] = r'\aj'
|
|
18
|
+
mdict['Annual Review of Astronomy and Astrophysics'] = r'\araa'
|
|
19
|
+
mdict['The Astrophysical Journal'] = r'\apj'
|
|
20
|
+
mdict['Publications of the Astronomical Society of the Pacific'] = r'\pasp'
|
|
21
|
+
mdict['Astronomy and Astrophysics'] = r'\aap'
|
|
22
|
+
mdict['Astronomy & Astrophysics'] = r'\aap'
|
|
23
|
+
mdict['Astronomy \& Astrophysics'] = r'\aap'
|
|
24
|
+
mdict['Monthly Notices of the Royal Astronomical Society: Letters'] = r'\mnras:l'
|
|
25
|
+
mdict['Monthly Notices of the Royal Astronomical Society'] = r'\mnras'
|
|
26
|
+
mdict['Nature'] = r'\nat'
|
|
27
|
+
|
|
28
|
+
# Sometimes, zotero randomly adds the arXiv ID as a note, even for
|
|
29
|
+
# published papers.
|
|
30
|
+
fdict = OrderedDict({})
|
|
31
|
+
fdict['note = {arXiv:'] = ''
|
|
32
|
+
|
|
33
|
+
with open(input_bib, 'r') as f:
|
|
34
|
+
lines = f.readlines()
|
|
35
|
+
|
|
36
|
+
for k,v in mdict.items():
|
|
37
|
+
for ix, l in enumerate(lines):
|
|
38
|
+
if k in l:
|
|
39
|
+
_newline = l.replace(k, v)
|
|
40
|
+
lines[ix] = _newline
|
|
41
|
+
|
|
42
|
+
for k in fdict.keys():
|
|
43
|
+
for ix, l in enumerate(lines):
|
|
44
|
+
if k in l:
|
|
45
|
+
lines.pop(ix)
|
|
46
|
+
|
|
47
|
+
with open(output_bib, 'w') as f:
|
|
48
|
+
f.writelines(lines)
|
|
49
|
+
|
|
50
|
+
print(f'made {output_bib}')
|
aesthetic/plot.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Plotting utilities that I re-use.
|
|
3
|
+
|
|
4
|
+
Contents:
|
|
5
|
+
set_style
|
|
6
|
+
set_style_grid
|
|
7
|
+
savefig
|
|
8
|
+
format_ax
|
|
9
|
+
"""
|
|
10
|
+
import os as _os
|
|
11
|
+
import numpy as np, matplotlib.pyplot as plt, matplotlib.style as _mplstyle, pandas as pd
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
|
|
14
|
+
_styles_dir = _os.path.join(_os.path.dirname(__file__), 'styles')
|
|
15
|
+
if _styles_dir not in _mplstyle.core.USER_LIBRARY_PATHS:
|
|
16
|
+
_mplstyle.core.USER_LIBRARY_PATHS.append(_styles_dir)
|
|
17
|
+
_mplstyle.reload_library()
|
|
18
|
+
|
|
19
|
+
def set_style(stylelist=['science']):
|
|
20
|
+
"""
|
|
21
|
+
Set styles using https://github.com/garrettj403/SciencePlots
|
|
22
|
+
|
|
23
|
+
Allowed in list:
|
|
24
|
+
'science', 'grid', 'ieee', 'scatter', 'notebook', 'no-latex',
|
|
25
|
+
'dark_background' + any matplotlib default styles (seaborn, etc).
|
|
26
|
+
|
|
27
|
+
Color cycles:
|
|
28
|
+
'high-vis', 'bright', 'vibrant', 'muted', 'retro'.
|
|
29
|
+
"""
|
|
30
|
+
if isinstance(stylelist, str):
|
|
31
|
+
stylelist = [stylelist]
|
|
32
|
+
plt.style.use(stylelist)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def savefig(fig, figpath, writepdf=True, dpi=450):
|
|
36
|
+
"""
|
|
37
|
+
Wrapper to matplotlib's fig.savefig that i) makes both a png and a pdf, and
|
|
38
|
+
ii) prints the time at which the file was saved.
|
|
39
|
+
"""
|
|
40
|
+
fig.savefig(figpath, dpi=dpi, bbox_inches='tight')
|
|
41
|
+
print(f'{datetime.utcnow().isoformat()}: made {figpath}')
|
|
42
|
+
|
|
43
|
+
if writepdf:
|
|
44
|
+
pdffigpath = figpath.replace('.png','.pdf')
|
|
45
|
+
fig.savefig(pdffigpath, bbox_inches='tight', dpi=dpi, pad_inches=0.05)
|
|
46
|
+
print(f'{datetime.utcnow().isoformat()}: made {pdffigpath}')
|
|
47
|
+
|
|
48
|
+
plt.close('all')
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def format_ax(ax):
|
|
52
|
+
ax.yaxis.set_ticks_position('both')
|
|
53
|
+
ax.xaxis.set_ticks_position('both')
|
|
54
|
+
ax.get_yaxis().set_tick_params(which='both', direction='in')
|
|
55
|
+
ax.get_xaxis().set_tick_params(which='both', direction='in')
|
|
56
|
+
ax.tick_params(axis='both', which='major', labelsize='small')
|
|
File without changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Matplotlib style for clean figures.
|
|
2
|
+
|
|
3
|
+
# Figure size
|
|
4
|
+
figure.figsize : 3.3, 2.5 # max width is 3.5 for single column
|
|
5
|
+
|
|
6
|
+
# Set x axis
|
|
7
|
+
xtick.direction : in
|
|
8
|
+
#xtick.major.size : 3
|
|
9
|
+
xtick.major.width : 0.65
|
|
10
|
+
#xtick.minor.size : 1.5
|
|
11
|
+
xtick.minor.width : 0.5
|
|
12
|
+
xtick.minor.visible : False
|
|
13
|
+
xtick.bottom : True
|
|
14
|
+
|
|
15
|
+
# Set y axis
|
|
16
|
+
ytick.direction : in
|
|
17
|
+
#ytick.major.size : 3
|
|
18
|
+
ytick.major.width : 0.65
|
|
19
|
+
#ytick.minor.size : 1.5
|
|
20
|
+
ytick.minor.width : 0.5
|
|
21
|
+
ytick.minor.visible : False
|
|
22
|
+
ytick.left : True
|
|
23
|
+
|
|
24
|
+
## Font sizes
|
|
25
|
+
#axes.labelsize: 8
|
|
26
|
+
#xtick.labelsize: 7
|
|
27
|
+
#ytick.labelsize: 7
|
|
28
|
+
#legend.fontsize: 7
|
|
29
|
+
#font.size: 7
|
|
30
|
+
|
|
31
|
+
# Font Family
|
|
32
|
+
font.family : Arial
|
|
33
|
+
mathtext.fontset : custom
|
|
34
|
+
mathtext.rm : Arial
|
|
35
|
+
mathtext.it : Arial:italic
|
|
36
|
+
mathtext.bf : Arial:bold
|
|
37
|
+
mathtext.sf : Arial
|
|
38
|
+
|
|
39
|
+
## Always save as 'tight'
|
|
40
|
+
#savefig.bbox : tight
|
|
41
|
+
#savefig.pad_inches : 0.01 # Use virtually all space when we specify figure dimensions
|
|
42
|
+
|
|
43
|
+
# LaTeX packages
|
|
44
|
+
text.latex.preamble : \usepackage{amsmath} \usepackage{amssymb} \usepackage{sfmath}
|
|
45
|
+
|
|
46
|
+
# Axis spines
|
|
47
|
+
axes.spines.top: False
|
|
48
|
+
axes.spines.right: False
|
|
49
|
+
axes.spines.left: True # display axis spines
|
|
50
|
+
axes.spines.bottom: True
|
|
51
|
+
|
|
52
|
+
#axes.labelweight: bold
|
|
53
|
+
# Set line widths
|
|
54
|
+
axes.linewidth : 0.65
|
|
55
|
+
grid.linewidth : 0.5
|
|
56
|
+
lines.linewidth : 1.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Matplotlib style: clean white on black.
|
|
2
|
+
# In general, they advocate for all fonts to be sans serif
|
|
3
|
+
# and all font sizes in a figure to be 7 pt and panel labels to be 8 pt bold.
|
|
4
|
+
|
|
5
|
+
# Figure size
|
|
6
|
+
figure.figsize : 3.3, 2.5 # max width is 3.5 for single column
|
|
7
|
+
|
|
8
|
+
# Set x axis
|
|
9
|
+
xtick.direction : in
|
|
10
|
+
#xtick.major.size : 3
|
|
11
|
+
xtick.major.width : 0.65
|
|
12
|
+
#xtick.minor.size : 1.5
|
|
13
|
+
xtick.minor.width : 0.5
|
|
14
|
+
xtick.minor.visible : False
|
|
15
|
+
xtick.bottom : True
|
|
16
|
+
xtick.color : White
|
|
17
|
+
|
|
18
|
+
# Set y axis
|
|
19
|
+
ytick.direction : in
|
|
20
|
+
#ytick.major.size : 3
|
|
21
|
+
ytick.major.width : 0.65
|
|
22
|
+
#ytick.minor.size : 1.5
|
|
23
|
+
ytick.minor.width : 0.5
|
|
24
|
+
ytick.minor.visible : False
|
|
25
|
+
ytick.left : True
|
|
26
|
+
ytick.color : White
|
|
27
|
+
|
|
28
|
+
## Font sizes
|
|
29
|
+
#axes.labelsize: 8
|
|
30
|
+
#xtick.labelsize: 7
|
|
31
|
+
#ytick.labelsize: 7
|
|
32
|
+
#legend.fontsize: 7
|
|
33
|
+
#font.size: 7
|
|
34
|
+
|
|
35
|
+
# Font Family
|
|
36
|
+
font.family : Arial
|
|
37
|
+
mathtext.fontset : custom
|
|
38
|
+
mathtext.rm : Arial
|
|
39
|
+
mathtext.it : Arial:italic
|
|
40
|
+
mathtext.bf : Arial:bold
|
|
41
|
+
mathtext.sf : Arial
|
|
42
|
+
|
|
43
|
+
# Font color
|
|
44
|
+
text.color: white
|
|
45
|
+
axes.labelcolor: white
|
|
46
|
+
|
|
47
|
+
# Background color
|
|
48
|
+
figure.facecolor: black
|
|
49
|
+
axes.facecolor: black
|
|
50
|
+
|
|
51
|
+
## Always save as 'tight'
|
|
52
|
+
#savefig.bbox : tight
|
|
53
|
+
#savefig.pad_inches : 0.01 # Use virtually all space when we specify figure dimensions
|
|
54
|
+
|
|
55
|
+
# LaTeX packages
|
|
56
|
+
text.latex.preamble : \usepackage{amsmath} \usepackage{amssymb} \usepackage{sfmath}
|
|
57
|
+
|
|
58
|
+
# Axis spines
|
|
59
|
+
axes.spines.top: False
|
|
60
|
+
axes.spines.right: False
|
|
61
|
+
axes.spines.left: True # display axis spines
|
|
62
|
+
axes.spines.bottom: True
|
|
63
|
+
axes.edgecolor : white
|
|
64
|
+
|
|
65
|
+
# Some might like to set:
|
|
66
|
+
#axes.labelweight: bold
|
|
67
|
+
|
|
68
|
+
# Set line widths
|
|
69
|
+
axes.linewidth : 0.65
|
|
70
|
+
grid.linewidth : 0.5
|
|
71
|
+
lines.linewidth : 1.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Add grid lines and turn the legend frame on
|
|
2
|
+
|
|
3
|
+
# Grid lines
|
|
4
|
+
axes.grid : True
|
|
5
|
+
grid.linestyle : :
|
|
6
|
+
grid.color : k
|
|
7
|
+
grid.alpha : 0.5
|
|
8
|
+
grid.linewidth : 0.5
|
|
9
|
+
|
|
10
|
+
# Legend
|
|
11
|
+
legend.frameon : True
|
|
12
|
+
legend.framealpha : 1.0
|
|
13
|
+
legend.fancybox : True
|
|
14
|
+
legend.numpoints : 1
|
|
15
|
+
|
|
16
|
+
# Font Family
|
|
17
|
+
font.family : Arial
|
|
18
|
+
mathtext.fontset : custom
|
|
19
|
+
mathtext.rm : Arial
|
|
20
|
+
mathtext.it : Arial:italic
|
|
21
|
+
mathtext.bf : Arial:bold
|
|
22
|
+
mathtext.sf : Arial
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Matplotlib style for Jupyter notebooks
|
|
2
|
+
|
|
3
|
+
# # Set default figure size
|
|
4
|
+
# figure.figsize : 8, 6
|
|
5
|
+
|
|
6
|
+
# Set x axis
|
|
7
|
+
xtick.major.size : 6
|
|
8
|
+
xtick.major.width : 1
|
|
9
|
+
xtick.minor.size : 3
|
|
10
|
+
xtick.minor.width : 1
|
|
11
|
+
|
|
12
|
+
# Set y axis
|
|
13
|
+
ytick.major.size : 6
|
|
14
|
+
ytick.major.width : 1
|
|
15
|
+
ytick.minor.size : 3
|
|
16
|
+
ytick.minor.width : 1
|
|
17
|
+
|
|
18
|
+
# # Fontsizes
|
|
19
|
+
# xtick.labelsize : 16
|
|
20
|
+
# ytick.labelsize : 16
|
|
21
|
+
# legend.fontsize : 16
|
|
22
|
+
# legend.title_fontsize : 16
|
|
23
|
+
# axes.titlesize : 16
|
|
24
|
+
# axes.labelsize : 16
|
|
25
|
+
|
|
26
|
+
# Set line widths
|
|
27
|
+
axes.linewidth : 1
|
|
28
|
+
grid.linewidth : 1
|
|
29
|
+
lines.linewidth : 2.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# Font Family
|
|
33
|
+
font.family : Arial
|
|
34
|
+
mathtext.fontset : custom
|
|
35
|
+
mathtext.rm : Arial
|
|
36
|
+
mathtext.it : Arial:italic
|
|
37
|
+
mathtext.bf : Arial:bold
|
|
38
|
+
mathtext.sf : Arial
|
|
39
|
+
|
|
40
|
+
# # Use LaTeX for math formatting
|
|
41
|
+
# text.usetex : False
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Matplotlib style for scatter plots
|
|
2
|
+
|
|
3
|
+
# Set markers (style, color, no lines)
|
|
4
|
+
axes.prop_cycle : (cycler('marker', ['o', 's', '^', 'v', '<', '>', 'd']) + cycler('color', ['0C5DA5', '00B945', 'FF9500', 'FF2C00', '845B97', '474747', '9e9e9e']) + cycler('ls', [' ', ' ', ' ', ' ', ' ', ' ', ' ']))
|
|
5
|
+
|
|
6
|
+
# # Set marker size
|
|
7
|
+
# lines.markersize : 3
|
|
8
|
+
|
|
9
|
+
# Font Family
|
|
10
|
+
font.family : Arial
|
|
11
|
+
mathtext.fontset : custom
|
|
12
|
+
mathtext.rm : Arial
|
|
13
|
+
mathtext.it : Arial:italic
|
|
14
|
+
mathtext.bf : Arial:bold
|
|
15
|
+
mathtext.sf : Arial
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Matplotlib style for scientific plotting
|
|
2
|
+
# This is the base style for "SciencePlots"
|
|
3
|
+
# see: https://github.com/garrettj403/SciencePlots
|
|
4
|
+
|
|
5
|
+
# Set color cycle: blue, green, yellow, red, violet, gray
|
|
6
|
+
#axes.prop_cycle : cycler('color', ['0C5DA5', '00B945', 'FF9500', 'FF2C00', '845B97', '474747', '9e9e9e'])
|
|
7
|
+
|
|
8
|
+
# # Set default figure size
|
|
9
|
+
# figure.figsize : 3.5, 2.625
|
|
10
|
+
|
|
11
|
+
# Set x axis
|
|
12
|
+
xtick.direction : in
|
|
13
|
+
xtick.major.size : 3
|
|
14
|
+
xtick.major.width : 0.5
|
|
15
|
+
xtick.minor.size : 1.5
|
|
16
|
+
xtick.minor.width : 0.5
|
|
17
|
+
xtick.minor.visible : True
|
|
18
|
+
xtick.top : True
|
|
19
|
+
|
|
20
|
+
# Set y axis
|
|
21
|
+
ytick.direction : in
|
|
22
|
+
ytick.major.size : 3
|
|
23
|
+
ytick.major.width : 0.5
|
|
24
|
+
ytick.minor.size : 1.5
|
|
25
|
+
ytick.minor.width : 0.5
|
|
26
|
+
ytick.minor.visible : True
|
|
27
|
+
ytick.right : True
|
|
28
|
+
|
|
29
|
+
# Set line widths
|
|
30
|
+
axes.linewidth : 0.5
|
|
31
|
+
grid.linewidth : 0.5
|
|
32
|
+
lines.linewidth : 1.
|
|
33
|
+
|
|
34
|
+
# Axis spines
|
|
35
|
+
axes.spines.top: True
|
|
36
|
+
axes.spines.right: True
|
|
37
|
+
axes.spines.left: True # display axis spines
|
|
38
|
+
axes.spines.bottom: True
|
|
39
|
+
|
|
40
|
+
# Restore <=mpl 3.6 default font sizes
|
|
41
|
+
# font.size: 7 # Default font size for text elements
|
|
42
|
+
# axes.labelsize: 8 # Font size for axis labels
|
|
43
|
+
# xtick.labelsize: 7 # Font size for x-tick labels
|
|
44
|
+
# ytick.labelsize: 7 # Font size for y-tick labels
|
|
45
|
+
# legend.fontsize: 6 # Font size for legend labels
|
|
46
|
+
# figure.titlesize: 8 # Font size for figure titles
|
|
47
|
+
# axes.titlesize: 8 # Font size for axes titles
|
|
48
|
+
|
|
49
|
+
# # Remove legend frame
|
|
50
|
+
# legend.frameon : False
|
|
51
|
+
|
|
52
|
+
# # Always save as 'tight'
|
|
53
|
+
# savefig.bbox : tight
|
|
54
|
+
# savefig.pad_inches : 0.05
|
|
55
|
+
|
|
56
|
+
# Font Family
|
|
57
|
+
font.family : Arial
|
|
58
|
+
mathtext.fontset : custom
|
|
59
|
+
mathtext.rm : Arial
|
|
60
|
+
mathtext.it : Arial:italic
|
|
61
|
+
mathtext.bf : Arial:bold
|
|
62
|
+
mathtext.sf : Arial
|
|
63
|
+
|
|
64
|
+
# # Use LaTeX for math formatting
|
|
65
|
+
# text.usetex : True
|
|
66
|
+
# text.latex.preamble : \usepackage{amsmath}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Matplotlib style for scientific plotting
|
|
2
|
+
# This is the base style for "SciencePlots"
|
|
3
|
+
# see: https://github.com/garrettj403/SciencePlots
|
|
4
|
+
|
|
5
|
+
# Set color cycle: blue, green, yellow, red, violet, gray
|
|
6
|
+
#axes.prop_cycle : cycler('color', ['0C5DA5', '00B945', 'FF9500', 'FF2C00', '845B97', '474747', '9e9e9e'])
|
|
7
|
+
|
|
8
|
+
# # Set default figure size
|
|
9
|
+
# figure.figsize : 3.5, 2.625
|
|
10
|
+
|
|
11
|
+
# Set x axis
|
|
12
|
+
xtick.direction : in
|
|
13
|
+
xtick.major.size : 3
|
|
14
|
+
xtick.major.width : 0.5
|
|
15
|
+
xtick.minor.size : 1.5
|
|
16
|
+
xtick.minor.width : 0.5
|
|
17
|
+
xtick.minor.visible : True
|
|
18
|
+
xtick.top : True
|
|
19
|
+
xtick.color : White
|
|
20
|
+
|
|
21
|
+
# Set y axis
|
|
22
|
+
ytick.direction : in
|
|
23
|
+
ytick.major.size : 3
|
|
24
|
+
ytick.major.width : 0.5
|
|
25
|
+
ytick.minor.size : 1.5
|
|
26
|
+
ytick.minor.width : 0.5
|
|
27
|
+
ytick.minor.visible : True
|
|
28
|
+
ytick.right : True
|
|
29
|
+
ytick.color : White
|
|
30
|
+
|
|
31
|
+
# Set line widths
|
|
32
|
+
axes.linewidth : 0.5
|
|
33
|
+
grid.linewidth : 0.5
|
|
34
|
+
lines.linewidth : 1.
|
|
35
|
+
|
|
36
|
+
# Axis spines
|
|
37
|
+
axes.spines.top: True
|
|
38
|
+
axes.spines.right: True
|
|
39
|
+
axes.spines.left: True # display axis spines
|
|
40
|
+
axes.spines.bottom: True
|
|
41
|
+
axes.edgecolor : white
|
|
42
|
+
|
|
43
|
+
# Font color
|
|
44
|
+
text.color: white
|
|
45
|
+
axes.labelcolor: white
|
|
46
|
+
|
|
47
|
+
# Background color
|
|
48
|
+
figure.facecolor: black
|
|
49
|
+
axes.facecolor: black
|
|
50
|
+
|
|
51
|
+
# # Remove legend frame
|
|
52
|
+
# legend.frameon : False
|
|
53
|
+
|
|
54
|
+
# # Always save as 'tight'
|
|
55
|
+
# savefig.bbox : tight
|
|
56
|
+
# savefig.pad_inches : 0.05
|
|
57
|
+
|
|
58
|
+
# Font Family
|
|
59
|
+
font.family : Arial
|
|
60
|
+
mathtext.fontset : custom
|
|
61
|
+
mathtext.rm : Arial
|
|
62
|
+
mathtext.it : Arial:italic
|
|
63
|
+
mathtext.bf : Arial:bold
|
|
64
|
+
mathtext.sf : Arial
|
|
65
|
+
|
|
66
|
+
# # Use LaTeX for math formatting
|
|
67
|
+
# text.usetex : True
|
|
68
|
+
# text.latex.preamble : \usepackage{amsmath}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aesthetic
|
|
3
|
+
Version: 0.10
|
|
4
|
+
Summary: a e s t h e t i c
|
|
5
|
+
Home-page: https://github.com/lgbouma/aesthetic
|
|
6
|
+
Download-URL: https://github.com/lgbouma/aesthetic/archive/refs/tags/v09.tar.gz
|
|
7
|
+
Author: Luke Bouma
|
|
8
|
+
Author-email: bouma.luke@gmail.com
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: astronomy,matplotlib-style-sheets
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: matplotlib
|
|
20
|
+
Provides-Extra: tests
|
|
21
|
+
Requires-Dist: pytest==3.8.2; extra == "tests"
|
|
22
|
+
Dynamic: download-url
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# a e s t h e t i c
|
|
26
|
+
|
|
27
|
+
Luke's matplotlib style sheets.
|
|
28
|
+
Remixed from John Garrett's [SciencePlots](https://github.com/garrettj403/SciencePlots).
|
|
29
|
+
|
|
30
|
+
Preferences:
|
|
31
|
+
* Avoid constantly repeating matplotlib calls to prettify plots.
|
|
32
|
+
* Default font: Arial (not DejaVu Sans, which many systems don't have installed by default)
|
|
33
|
+
* Don't draw right and top axis spines unless they provide function.
|
|
34
|
+
* White on black reduces eye strain; make generating white on black figures easy by using `*_wob` style sheets.
|
|
35
|
+
|
|
36
|
+
__install__
|
|
37
|
+
|
|
38
|
+
_...via pip_: `pip install aesthetic`
|
|
39
|
+
|
|
40
|
+
_...via local clone_: `git clone git@github.com:lgbouma/aesthetic.git; cd aesthetic; pip install -e . `
|
|
41
|
+
|
|
42
|
+
__examples__
|
|
43
|
+
|
|
44
|
+
for plot styles, see the [test driver](https://github.com/lgbouma/aesthetic/blob/master/tests/make_test_plot.py).
|
|
45
|
+
the general syntax follows:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
from aesthetic import set_style
|
|
49
|
+
set_style("clean")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
<img src="https://raw.githubusercontent.com/lgbouma/aesthetic/refs/heads/master/results/plot_clean.png?v=2" width="500">
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
set_style("clean_wob")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
<img src="https://raw.githubusercontent.com/lgbouma/aesthetic/refs/heads/master/results/plot_clean_wob.png?v=2" width="500">
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
set_style("science")
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
<img src="https://raw.githubusercontent.com/lgbouma/aesthetic/refs/heads/master/results/plot_science.png" width="500">
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
set_style("science_wob")
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
<img src="https://raw.githubusercontent.com/lgbouma/aesthetic/refs/heads/master/results/plot_science_wob.png?v=2" width="500">
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
So if you wanted to make four different versions of the same plot with responsive colors:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
from aesthetic.plot import set_style
|
|
78
|
+
|
|
79
|
+
import numpy as np, matplotlib.pyplot as plt, matplotlib as mpl
|
|
80
|
+
|
|
81
|
+
def make_plot(style):
|
|
82
|
+
x = np.linspace(0,10,1000)
|
|
83
|
+
y = (x/100)**3 + 5*np.sin(x)
|
|
84
|
+
_x, _y = np.arange(2, 8, 0.5), np.arange(2, 8, 0.5)
|
|
85
|
+
|
|
86
|
+
fig, ax = plt.subplots(figsize=(3,2.5))
|
|
87
|
+
cs = [None]*3 if '_wob' not in style else ['cyan','lime','yellow']
|
|
88
|
+
ax.plot(x, y, label=f'style: {style}', color=cs[0])
|
|
89
|
+
ax.plot(x, y+3, color=cs[1])
|
|
90
|
+
ax.plot(x, y+6, color=cs[2])
|
|
91
|
+
_yerr = np.abs(np.random.normal(2, 1, _x.size))
|
|
92
|
+
c = 'k' if '_wob' not in style else 'w'
|
|
93
|
+
ax.errorbar(_x, _y, yerr=_yerr, marker='o', elinewidth=0.5, lw=0, c=c, markersize=2)
|
|
94
|
+
ax.update({ 'xlabel': r'x [units]', 'ylabel': r'y [units]' })
|
|
95
|
+
ax.legend(fontsize='small')
|
|
96
|
+
return fig
|
|
97
|
+
|
|
98
|
+
if __name__ == '__main__':
|
|
99
|
+
styles = ['clean', 'science', 'clean_wob', 'science_wob']
|
|
100
|
+
for style in styles:
|
|
101
|
+
set_style(style)
|
|
102
|
+
fig = make_plot(style)
|
|
103
|
+
fig.savefig(f'../results/plot_{style}.png', bbox_inches='tight', dpi=400)
|
|
104
|
+
mpl.rc_file_defaults()
|
|
105
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
aesthetic/__init__.py,sha256=6ZnJqIw2D2SEYphDkVmbL-gzvpEia3ReeG2N1H9Jv7s,579
|
|
2
|
+
aesthetic/paper.py,sha256=RofiYUC0DAarvaS7RG-FUoi1ihBiUfzyeH3HQRqHoH8,1769
|
|
3
|
+
aesthetic/plot.py,sha256=YbO9H52r9LYUcifb0HLjeSrj1LjSbOX-7I2hw1X3yts,1778
|
|
4
|
+
aesthetic/styles/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
aesthetic/styles/clean.mplstyle,sha256=u4SsFK7c6I6svZpuHUhSzih_Nvr1Vr24oLLdGUJiSdw,1243
|
|
6
|
+
aesthetic/styles/clean_wob.mplstyle,sha256=fZmN9jGA1dDI7d4cYb5V0ja8eBdq9CXyANdoVRzSkf4,1595
|
|
7
|
+
aesthetic/styles/grid.mplstyle,sha256=jITL2nHxflp_-tbhmK1Yzf1HRFRP-CNCWJQmw5L3Hv4,427
|
|
8
|
+
aesthetic/styles/notebook.mplstyle,sha256=SUqiinag3bUEigXJ9SAubUIR8fu1FRwfpOjcXQ8r_i4,765
|
|
9
|
+
aesthetic/styles/scatter.mplstyle,sha256=mOD-F86j3URzxgsLjrGqXl93WkRY-28GZxIhjHcQQ1k,515
|
|
10
|
+
aesthetic/styles/science.mplstyle,sha256=d3OuBjyIJfvRYby1BQ8ZP3JYPYHGJWkLsPypat-lRrU,1736
|
|
11
|
+
aesthetic/styles/science_wob.mplstyle,sha256=bF1mqqrIbQ6AXMNHImhBZaxdyiuNINMmDVRkmjwKJtA,1519
|
|
12
|
+
aesthetic-0.10.dist-info/licenses/LICENSE,sha256=r4vpg5DQXHA-GyficrQf4DggjKN8QTAPRc88o_Jdn8E,1091
|
|
13
|
+
aesthetic-0.10.dist-info/METADATA,sha256=h56oQgjBQYs4vTN5dkJqJpB31CEpxfwAMa5L4Ga45VM,3446
|
|
14
|
+
aesthetic-0.10.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
15
|
+
aesthetic-0.10.dist-info/top_level.txt,sha256=ZoWm4gB1s0Mqao5seehnGWxfxVBspfqYFDX7w9YIMKA,10
|
|
16
|
+
aesthetic-0.10.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016-today Luke Bouma, and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aesthetic
|