def plot_all_to_latex(self, sec, mean_metrics, std_metrics, caption, file_path, file_name): plot = sec.new( Plot(plot_name=file_name, plot_path=file_path, position='th!', width=r'.27\textwidth', height=r'.25\textwidth', label=file_name, name='plot0', xshift=r'-.115\textwidth')) plot.caption = caption kwargs_per_plot = { 1: { 'as_float_env': False, 'at': '(plot0.south east)', 'anchor': 'south west', 'xshift': r'-.04\textwidth', 'name': 'plot1' }, 2: { 'as_float_env': False, 'at': '(plot1.south east)', 'anchor': 'south west', 'xshift': r'0.035\textwidth', 'name': 'plot2' }, 3: { 'as_float_env': False, 'at': '(plot2.south east)', 'anchor': 'south west', 'xshift': r'.11\textwidth', 'name': 'plot3' } } titles = { 'de': 'English-Deutsch', 'it': 'English-Italian', 'fi': 'English-Finnish', 'es': 'English-Spanish' } for i, language in enumerate(sorted(mean_metrics['accuracies'])): if i == 0: current_plot = plot else: current_plot = Plot(plot_name=file_name, plot_path=file_path, width=r'.27\textwidth', height=r'.25\textwidth', **kwargs_per_plot[i]) current_plot.tikzpicture.head = '' current_plot.tikzpicture.tail = '' x, y, std = np.array( list(mean_metrics['accuracies'][language].keys())).astype( int), np.array( list(mean_metrics['accuracies'] [language].values())).astype(float), np.array( list(std_metrics['accuracies'] [language].values())).astype(float) sorting = x.argsort() x, y, std = x[sorting], y[sorting], std[sorting] current_plot.add_plot(x, y, 'blue', 'ylabel near ticks', mark='*', line_width='1.2pt', mark_size='.9pt') current_plot.add_plot(x, y + 1.96 * std, name_path='upper', draw='none') current_plot.add_plot(x, y - 1.96 * std, name_path='lower', draw='none') current_plot.axis.append( '\\addplot[fill=blue!10] fill between[of=upper and lower];') current_plot.axis.kwoptions[ 'y tick label style'] = '{/pgf/number format/fixed zerofill, /pgf/number format/precision=1}' current_plot.x_min = np.floor(x.min()) current_plot.x_max = np.ceil(x.max()) y_max, y_min = (y + 1.96 * std).max(), (y - 1.96 * std).min() delta = y.max() - y.min() current_plot.y_min = y_min - delta / 2 current_plot.y_max = y_max + delta / 2 current_plot.title = titles[language] current_plot.plot_name += '_en_{}'.format(language) if i > 0: plot.tikzpicture += current_plot
ybar='0mm', xticklabel_style='{font=\\footnotesize}', xtick_style='{draw=none}', ytick_style='{draw=none}', ) plot.axis.options += ( 'nodes near coords', 'every node near coord/.append style={font=\\scriptsize}', ) plot.add_plot(x, y1, 'fill', draw='none', legend='Modèle 1') plot.add_plot(x, y2, 'fill', draw='none', legend='Modèle 2') plot.legend_position = 'north west' plot.y_min = 0 plot.y_max = 79 plot.x_min = 0.5 plot.x_ticks = x plot.x_ticks_labels = labels plot.x_label = 'Datasets' plot.y_label = "Précision (\%)" doc = Document('bar_chart_example', filepath='./examples/', doc_type='standalone') doc += plot doc.build(delete_files=['log', 'aux'])
color=f'{palette[i]}!50!black', line_cap='round', line_width='1pt', ) plot.add_plot( *quartiles, color=f'{palette[i]}!50!black', line_cap='round', line_width='2pt', ) plot.x_label = 'Attribut' plot.y_label = 'Taille (cm)' plot.x_ticks = [0, 1, 2, 3] plot.x_ticks_labels = [ 'Longueur\\\\ pétale', 'Largeur\\\\ pétale', 'Longueur\\\\ sépale', 'Largeur\\\\ sépale', ] plot.y_ticks = list(range(0, 11, 2)) plot.y_min = -.6 doc = Document('violin_plot_example', filepath='./examples/', doc_type='standalone') doc += plot doc.build(delete_files=['log', 'aux'])