""" functions for plotting style """ import matplotlib as mpl import matplotlib.pylab as pl import matplotlib.colors as cl import colormaps as cmaps import cmcrameri import numpy as np def get_style(color,ls='',errorbar = True,marker = 'o'): """ returns style dict for a color :param color: :return: """ style_dict = {'color':color, 'linestyle':ls, 'marker':marker, 'markerfacecolor' : cl.to_rgba(color,0.3), 'markeredgecolor':color} if errorbar: style_dict.update({'ecolor':(cl.to_rgba(color, 0.5))}) return style_dict RPTU_COLORS = { """ Corporate design colors of the RPTU """ "schwarz": "#000000", "weiß": "#ffffff", "schiefer": "#507289", "ozean": "#77b6ba", "nacht": "#042c58", "tag": "#6ab2e7", "petrol": "#006b6b", "apfel": "#26d07c", "pflaume": "#4c3575", "fuchsia": "#d13896", "himbeere": "#e31b4c", "mango": "#ffa252", "mango25pct": "#ffe8d4", } PYPLOT_STYLE_WHITE = { "figure.titlesize": 20, "figure.figsize": (5 * 1.61, 5), "figure.dpi": 300, "figure.constrained_layout.use": True, "savefig.dpi": 300, "lines.linewidth": 1.5, #"lines.marker": "none", "lines.markersize": 5, "lines.markeredgewidth": 1.2, "axes.linewidth": 1.5, "axes.titlesize": 15, "axes.labelsize": 12, "xtick.top": True, "xtick.bottom": True, "xtick.major.width": 1.5, "xtick.minor.width": 1.5, "xtick.major.size": 5, "xtick.minor.size": 3, "xtick.labelsize": 10, "xtick.direction": "in", "ytick.left": True, "ytick.right": True, "ytick.major.width": 1.5, "ytick.minor.width": 1.5, "ytick.major.size": 5, "ytick.minor.size": 3, "ytick.labelsize": 10, "ytick.direction": "in", "legend.title_fontsize": 16, "legend.fontsize": 10, #"mathtext.fontset": "stix", #"font.family": "Times New Roman", } def set_plot_style(style=PYPLOT_STYLE_WHITE): """ Set the plot style via rcParams. :param style: Style dictionary (default tweezertools.plot.PYPLOT_STYLE_WHITE) :type style: dict """ for key in style.keys(): pl.rcParams[key] = style[key] rptu_centered = mpl.colors.LinearSegmentedColormap.from_list("", [RPTU_COLORS[c] for c in ["nacht", "pflaume", "himbeere", "mango", "weiß"]]) rptu_centered = mpl.colors.ListedColormap(rptu_centered(np.linspace(0.1, 0.9, 256)), name="rptu_centered") mpl.colormaps.register(cmap=rptu_centered,name="rptu_centered")