susceptibility1/plotstyle.py
2024-04-11 13:21:46 +02:00

130 lines
7.5 KiB
Python

import __main__
import matplotlib as mpl
from plottools.plottools import *
from plottools.colors import *
from plottools.styles import *
from plottools.figure import *
from plottools.spines import *
from plottools.ticks import *
from plottools.labels import *
from plottools.axes import *
from plottools.text import *
from plottools.arrows import *
from plottools.insets import *
from plottools.scalebars import *
from plottools.significance import *
from plottools.styles import *
from plottools.grid import *
from plottools.legend import *
from plottools.tag import *
from IPython import embed
def plot_style(ns=__main__):
print('## added imports plotstyle.py version')
ns.palette = palettes['muted']
palette = ns.palette
ns.lwthick = 1.8
ns.lwthin = 1.0
generic_styles(colors='muted', lwthick=ns.lwthick, lwthin=ns.lwthin,
markerlarge=6.5, markersmall=4.0, mec=0.0, mew=0.8,
fillalpha=0.4, namespace=ns)
ns.lwspines = 1.0
make_fill_styles(ns, 'fs', 'Box', ['s', 'a'], lighter(palette['gray'], 0.6), 1.0, 0.0, 0.4)
make_line_styles(ns, 'ls', 'Spine', '', palette['black'], '-', ns.lwspines, clip_on=False)
make_line_styles(ns, 'ls', 'Line', '', palette['black'], '--', 0.7 * ns.lwthin)
make_line_styles(ns, 'ls', 'Grid', '', palette['gray'], '--', 0.7 * ns.lwthin)
make_line_styles(ns, 'ls', 'Dotted', '', palette['gray'], ':', 0.7 * ns.lwthin)
make_line_styles(ns, 'ls', 'Marker', '', palette['black'], '-', ns.lwthick, clip_on=False)
make_line_styles(ns, 'ls', 'EOD', '', palette['blue'], '-', 0.7, clip_on=False)
make_line_styles(ns, 'ls', 'EOD2', '', palette['purple'], '-', 0.7, clip_on=False)
make_line_styles(ns, 'ls', 'Fieldline', '', palette['purple'], '-', 0.7)
make_line_styles(ns, 'ls', 'Toblerone', '', palette['black'], ':', ns.lwthin)
ns.harmonics_pos = [palette['orange'], palette['blue'],
palette['red'], palette['darkgreen'],
palette['yellow'], palette['purple'],
palette['pink'], palette['darkgreen'],
palette['magenta'], palette['blue']]
ns.harmonics_neg = [palette['orange'], palette['lightblue'],
palette['magenta'], palette['lightgreen'],
palette['yellow'], palette['blue']]
make_line_styles(ns, 'ls', 'H0p', ['', 'm'], ns.harmonics_pos[0], '-', [ns.lwthick, ns.lwthin])
make_line_styles(ns, 'ls', 'H0n', ['', 'm'], ns.harmonics_neg[0], '-', [ns.lwthick, ns.lwthin])
make_line_styles(ns, 'ls', 'H%dp', '', ns.harmonics_pos[1:], '-', ns.lwthick)
make_line_styles(ns, 'ls', 'H%dn', '', ns.harmonics_neg[1:], '-', ns.lwthick)
make_line_styles(ns, 'ls', 'H%dpm', '', ns.harmonics_pos[1:], '-', ns.lwthin)
make_line_styles(ns, 'ls', 'H%dnm', '', ns.harmonics_neg[1:], '-', ns.lwthin)
ns.lsHp = [ns.lsH0p, ns.lsH1p, ns.lsH2p, ns.lsH3p, ns.lsH4p, ns.lsH5p,
ns.lsH6p, ns.lsH7p, ns.lsH8p, ns.lsH9p]
ns.lsHpm = [ns.lsH0pm, ns.lsH1pm, ns.lsH2pm, ns.lsH3pm, ns.lsH4pm, ns.lsH5pm,
ns.lsH6pm, ns.lsH7pm, ns.lsH8pm, ns.lsH9pm]
ns.lsHn = [ns.lsH0n, ns.lsH1n, ns.lsH2n, ns.lsH3n, ns.lsH4n, ns.lsH5n]
ns.lsHnm = [ns.lsH0nm, ns.lsH1nm, ns.lsH2nm, ns.lsH3nm, ns.lsH4nm, ns.lsH5nm]
arrow_style(ns, 'Line', dist=3.0, style='>', shrink=0, lw=0.6,
color=palette['black'], head_length=4, head_width=4)
arrow_style(ns, 'Linem', dist=3.0, style='>', shrink=0, lw=0.6,
color=palette['black'], head_length=3, head_width=3)
arrow_style(ns, 'Hertz', dist=3.0, style='>', shrink=0, lw=0.6,
color=palette['black'], head_length=3, head_width=3,
heads='<>', text='%.0f\u2009Hz', rotation='vertical', fontsize='x-small',
bbox=dict(boxstyle='round,pad=0.1', facecolor='white', edgecolor='none',
alpha=0.6))
arrow_style(ns, 'Point', dist=3.0, style='>>', shrink=0, lw=1.2,
color=palette['black'], head_length=8, head_width=6)
arrow_style(ns, 'PointSmall', dist=3.0, style='>>', shrink=0, lw=1,
color=palette['black'], head_length=5, head_width=5,
fontsize='small')
arrow_style(ns, 'Marker', dist=3.0, style='>>', shrink=0, lw=0.9,
color=palette['black'], head_length=5, head_width=5,
fontsize='small', ha='center', va='center',
bbox=dict(boxstyle='round, pad=0.1, rounding_size=0.4',
facecolor=palette['white'], edgecolor='none', alpha=0.6))
ns.tsEOD = dict(fontsize='x-small',
bbox=dict(boxstyle='round,pad=0.1', facecolor='white',
edgecolor='none', alpha=0.6))
ns.csLine = dict(colors=palette['gray'], linewidths=0.1, linestyles='solid')
ns.fishBody = dict(zorder=21, lw=0.1, edgecolor=palette['black'],
facecolor=palette['black'])
ns.fishFins = dict(zorder=20, lw=0.5, alpha=0.4,
edgecolor=lighter(palette['black'], 0.4),
facecolor=palette['black'])
ns.fishOpenBody = dict(zorder=21, lw=0.2,
edgecolor=palette['black'], facecolor='none')
ns.fishLightBody = dict(zorder=21, lw=0.2, edgecolor=palette['black'],
facecolor=lighter(palette['black'], 0.2))
ns.fishLightFins = dict(zorder=20, lw=0.2, edgecolor=palette['black'],
facecolor=lighter(palette['black'], 0.05))
# rc settings:
mpl.rcdefaults()
axes_params(xmargin=0, ymargin=0, zmargin=0, color='none')
cycle_colors = ['blue', 'red', 'orange', 'lightgreen', 'magenta', 'yellow', 'cyan', 'pink']
colors_params(ns.palette, cycle_colors, cmap='RdYlBu')
figure_params(color='none', format='pdf',
compression=6, fonttype=3, stripfonts=False)
grid_params(grid=False, axis='both', which='major', **ns.lsGrid)
labels_params(labelformat='{label} [{unit}]', labelsize='medium', labelweight='normal',
labelcolor='axes', labelpad=8,
xlabellocation='center', ylabellocation='center')
legend_params(fontsize='small', frameon=False, borderpad=0,
handlelength=1.5, handletextpad=0.5,
numpoints=1, scatterpoints=1, labelspacing=0.5, columnspacing=0.5)
scalebars_params(format_large='%.0f', format_small='%.1f',
lw=1.7, color=ns.palette['black'], capsize=0, clw=0.5,
font=dict(fontsize='medium', fontstyle='normal'))
spines_params(spines='lb', spines_offsets={'lrtb': 3}, spines_bounds={'lrtb': 'full'},
color=ns.lsSpine['color'], linewidth=ns.lsSpine['linewidth'],
flushx=1.0, flushy=1.0, extendx=1.0, extendy=1.0,
height=6, ratio=0.7, overhang=0.3)
tag_params(xoffs='auto', yoffs='auto', label='%A', minor_label='%A$_{\\rm %mi}$',
font=dict(fontsize='x-large', fontstyle='normal', fontweight='normal'))
text_params(font_size=9.0, font_family='sans-serif', color='axes', latex=True,
preamble=('p:pslatex', 'p:amssymb', 'p:sfmath', 'p:marvosym', 'p:[amssymb]SIunits',
r'\newcommand{\numcircled}[1]{\textcircled{\raisebox{-0.1ex}{#1}}}'))
ticks_params(xtick_minor=False, xtick_dir='out', xtick_size=3.5, minor_tick_frac=0.6,
xtick_major_width=None, xtick_minor_width=None, xtick_major_pad=None,
xtick_alignment='center', ytick_alignment='center_baseline',
xtick_color='axes', xtick_labelcolor='ticks', xtick_labelsize='medium')