import matplotlib.colors as mcolors import matplotlib as mpl import matplotlib.dates as mdates import matplotlib.pyplot as plt import datetime import numpy as np from IPython import embed ############################################################################################# # default fontsize plt.rcParams['font.size'] = 11 plt.rcParams['axes.linewidth'] = 2 ############################################################################################# # for boxplots props = dict(linewidth=2, color='black') props_a = dict(linewidth=2, color='#884ea0') props_e = dict(linewidth=2, color='#656565') flierprops = dict(marker='o', markeredgecolor='#656565', markersize=6, linestyle='none') ############################################################################################# # time boundaries of day, dusk, night and dawn time_bound = ['1900_01_01_6_30', '1900_01_01_16_30', '1900_01_01_18_30', '1900_01_02_4_30', '1900_01_02_6_30', '1900_01_02_16_30'] time_boxes = [] for i in range(len(time_bound)): time_boxes.append(datetime.datetime.strptime(time_bound[i], '%Y_%m_%d_%H_%M')) datetime_box = mdates.date2num(time_boxes) # bin length for activity calculations in second bin_len = 5 ############################################################################################# # colors color_efm = ['#2e4053', '#ab1717', '#004d8d', '#000000'] color_diffdays = ['#1b2631', '#2e4053', '#5d6d7e', '#aeb6bf'] cd = ['#566573', '#2c3e50', '#abb2b9', '#2471a3', '#1a5276', '#a9cce3'] cm20c = plt.cm.get_cmap('tab20c') color2 = ['#f39c12', '#d35400', '#fad7a0', '#e59866', '#c0392b', '#d98880', '#f1c40f'] color_dadunida = ['#DFD13A', '#c0392b', '#62285B', '#CE7227'] farben = list(mcolors.CSS4_COLORS) color_vec = [] for i in range(len(farben)): color_vec.append(mcolors.CSS4_COLORS[farben[i]]) color_vec = sorted(color_vec) ############################################################################################# # labels labels = ['$\it{Eigenmannia\,sp.}$', '$\it{A.\,macrostomus}\,\u2640$', '$\it{A.\,macrostomus}\,\u2642$', 'unknown'] ############################################################################################# # plot params fs = 11 # font_size fs_ticks = 11 # fs_ticks lw = 2 # linewidth a = 0.3 # alpha ms = 7 h_bins = 30 # hist_bins save_path = '../../thesis/Figures/Results/' save_path_pres = '../../pres_ergebnisse/figures/' inch = 2.45 ############################################################################################# # for nice plots def nice_ax(ax): ''' Makes nice x and y axis: top and right axis invisible and axis width = 2 and axis ticks labelsize = 11 :param ax: :return: ''' ax.spines["top"].set_visible(False) ax.spines["right"].set_visible(False) ax.tick_params(width=2) ax.tick_params(axis='both', which='major', labelsize=11) mpl.axes.Axes.make_nice_ax = nice_ax def beau_time_channel_axis(ax): ''' Makes nice axis for trajectory plots: top and right axis invisible and axis width = 2 and axis ticks labelsize = 11 white line for the gap: y = 7.5 y ticks and yticklabels: ticks at each electrode, labels at every second x and y labels :param ax: :return: ''' ax.spines["top"].set_visible(False) ax.spines["right"].set_visible(False) ax.tick_params(width=2) ax.tick_params(axis='both', which='major', labelsize=11) # ax.set_ylim([0, 15]) ax.axhline(7.5, xmin=0, xmax=15, color='white', lw=4) # ax.set_yticklabels([1, 3, 5, 7, 14, 16, 18, 20]) ax.set_yticks([0, 1, 2, 3, 4, 5, 6, 7, 7.5, 8, 9, 10, 11, 12, 13, 14, 15]) ax.set_yticklabels(['1', '', '3', '', '5', '', '7', '', 'gap', '', '10', '', '12', '', '14', '', '16']) # ax.set_yticklabels([0, 0, 2, 4, 6, 13, 15, 17, 19]) ax.invert_yaxis() ax.set_xlabel('Time', fontsize=11) ax.set_ylabel('Electrode', fontsize=11) mpl.axes.Axes.beautimechannelaxis = beau_time_channel_axis def timeaxis(ax): ''' Makes nice time axis for datetime x values: top and right axis invisible and axis width = 2 and axis ticks labelsize = 11 converts the x ticks in the date format into a real time axis of the form H:M :param ax: :return: ''' ax.spines["top"].set_visible(False) ax.spines["right"].set_visible(False) ax.tick_params(width=2) ax.tick_params(axis='both', which='major', labelsize=11) ax.xaxis_date() date_format = mdates.DateFormatter('%H:%M') # date_format = mdates.DateFormatter('%d.%m.%Y %H:%M') ax.xaxis.set_major_formatter(date_format) mpl.axes.Axes.timeaxis = timeaxis