#!/usr/bin/env python3 # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.lines as lines def set_size(width, fraction=1): """ Set aesthetic figure dimensions to avoid scaling in latex. Parameters ---------- width: float Width in pts (\\the\\textwidth) fraction: float Fraction of the width which you wish the figure to occupy Returns ------- fig_dim: tuple Dimensions of figure in inches """ # Width of figure fig_width_pt = width * fraction # Convert from pt to inches inches_per_pt = 1 / 72.27 # Golden ratio to set aesthetic figure height golden_ratio = (5 ** 0.5 - 1) / 2 # Figure width in inches fig_width_in = fig_width_pt * inches_per_pt # Figure height in inches fig_height_in = fig_width_in * golden_ratio return fig_width_in, fig_height_in def config_plt(): plt.rc('font', size=11, family='Latin Modern Roman') plt.rc('text', usetex=True) plt.rc('xtick', labelsize=11) plt.rc('ytick', labelsize=11) plt.rc('axes', labelsize=11) def get_colors(l, v): color_palette = [ '#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf', ] return color_palette[l.index(v)], '#888888' def fix_log_rects(bar, e = 1e-4): for rect in bar.patches: if rect.get_y() == 0: rect.set_y(e) rect.set_height(rect.get_height() - e)