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
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'])
plot_path='./examples/', plot_name='lineplot_example', as_float_env=False, grid_style=('gray!35', 'ultra thin'), width='7cm', height='6cm', ylabel_style='{yshift=-3.5mm}', ) plot.add_plot(x * 1000, y1, label='\\scriptsize$p=10$') plot.add_plot(x * 1000, y2, label='\\scriptsize$p=30$') plot.add_plot(x * 1000, y3, label='\\scriptsize$p=50$') plot.add_plot(x * 1000, y4, label='\\scriptsize$p=75$') plot.add_plot(x * 1000, y5, label='\\scriptsize$p=100$') plot.y_min = 0 plot.y_max = 6.2 plot.x_min = 0 plot.x_max = 900 plot.x_label = 'Abscisse (unité)' plot.y_label = 'Ordonnée (unité)' doc = Document('lineplot_example', filepath='./examples/', doc_type='standalone') doc += plot doc.build(delete_files=['log', 'aux'])