import numpy as np import vertical_stack # Note: LaTeX and PPTX-backend do not support html files # if test_html is True, we only generate the figure with the html backend test_html = False # PNG test blue = [82, 110, 186] img_blue = np.tile([x / 255 for x in blue], (32, 32, 1)) img_png = figuregen.PNG(img_blue) if test_html: # HTML test figuregen.figure(vertical_stack.v_grids, width_cm=15., filename='v-stacked.html') htmlfile = os.path.abspath('v-stacked.html') img_test = figuregen.HTML(htmlfile, aspect_ratio=0.3) else: # PDF test figuregen.figure(vertical_stack.v_grids, width_cm=15., filename='v-stacked.pdf') pdffile = os.path.abspath('v-stacked.pdf') img_test = figuregen.PDF(pdffile) images = [ img_test, img_png, ]
names = ["Reference"] names.extend(method_names) return FullSizeWithCrops( reference_image=sio.read(os.path.join(dirname, "Reference.exr")), method_images=[ sio.read(os.path.join(dirname, name, "Render.exr")) for name in method_names ], method_names=names, crops=[ Cropbox(top=345, left=25, width=64, height=48, scale=4), Cropbox(top=155, left=200, width=64, height=48, scale=4), ] ).figure if __name__ == "__main__": result_dir = sys.argv[1] method_names = [] for i in range(2, len(sys.argv)): method_names.append(sys.argv[i]) # Find all scenes by enumerating the result directory rows = [] for path in os.listdir(result_dir): if not os.path.isdir(os.path.join(result_dir, path)): continue rows.extend(make_figure(os.path.join(result_dir, path), method_names)) figuregen.figure(rows, 18, os.path.join(result_dir, "Overview.pdf"))
left=200, height=96, width=128, scale=5), Cropbox(top=100, left=450, height=96, width=128, scale=5), ], method_names=[ "Reference", "Path Tracer", "UPS+MCMC", "Radiance-based", "Ours" ]).figure figuregen.figure(figure, width_cm=17.7, filename="full_size_with_crops.pdf") try: from figuregen.util import jupyter jupyter.convert('full_size_with_crops.pdf', 300) except: print('Warning: pdf could not be converted to png') # Create the same figure again, but this time with the crops on the right hand side of each image figure = FullSizeWithCrops(reference_image=sio.read("images/pool/pool.exr"), method_images=[ sio.read("images/pool/pool-60s-path.exr"), sio.read("images/pool/pool-60s-radiance.exr"), sio.read("images/pool/pool-60s-full.exr"), ], crops=[
s_img.get_end_positions(), linewidth_pt=0.5, color=[0, 0, 0]) top_grid.set_col_titles('top', ['Horizontal Split', 'Vertical Split', 'C)', 'D)']) # LAYOUT: Specify paddings (unit: mm) top_lay = top_grid.get_layout() top_lay.set_padding(column=1.0, right=1.5) top_lay.set_col_titles('top', field_size_mm=5.0) if __name__ == "__main__": width_cm = 15 basename = "split-comparison" figuregen.figure([[top_grid]], width_cm=width_cm, filename=basename + '.pdf', backend=figuregen.PdfBackend(intermediate_dir="log")) figuregen.figure([[top_grid]], width_cm=width_cm, filename=basename + '.pptx') figuregen.figure([[top_grid]], width_cm=width_cm, filename=basename + '.html') try: from figuregen.util import jupyter jupyter.convert(basename + '.pdf', 300) except: print('Warning: pdf could not be converted to png')
grid.set_col_titles("top", variance_captions) grid.get_layout().set_col_titles("top", 3, offset_mm=0.5, fontsize=8) # Add space between the rows (needs to be removed for the last one) grid.get_layout().set_padding(bottom=2) return [grid] rows = [ make_row("BalanceOptimal", "1) Product", problem_range=[0,2.5]), make_row("Defensive", "2) Defensive", problem_range=[0,2.5]), make_row("Stratified", "3) Stratified", True, problem_range=[0,4.5], show_titles=True), ] # Remove bottom padding from the last row rows[-1][0].get_layout().set_padding(bottom=0) if __name__ == "__main__": import time start = time.time() figuregen.figure(rows, 15.4, "plotgrid.pdf") figuregen.figure(rows, 15.4, "plotgrid.pptx") figuregen.figure(rows, 15.4, "plotgrid.html") print(time.time() - start) try: from figuregen.util import jupyter jupyter.convert('plotgrid.pdf', 300) except: print('Warning: pdf could not be converted to png')
txt_color=[255, 255, 255]) grid.set_title('south', 'Bottom Title') #use defaults grid.set_title('right', 'Right Title') #use defaults grid.set_title('left', 'Left Title') layout.set_title('left', 4., offset_mm=2., fontsize=12) # Row and column titles grid.set_row_titles('left', ['Row titles', 'are better']) layout.set_row_titles('left', 10., offset_mm=1., fontsize=9, txt_rotation=0, bg_color=[colors[4], colors[2]]) grid.set_col_titles('north', ['Column titles', 'are', 'the best']) #layout.set_col_titles('north', 10., offset_mm=1., fontsize=9, bg_color=[200, 180, 220]) if __name__ == "__main__": figuregen.figure([[grid]], width_cm=18., filename='single-grid.pdf') figuregen.figure([[grid]], width_cm=18., filename='single-grid.pptx') figuregen.figure([[grid]], width_cm=18., filename='single-grid.html') try: from figuregen.util import jupyter jupyter.convert('single-grid.pdf', 300) except: print('Warning: pdf could not be converted to png')
sio.read("images/pool/pool-60s-radiance.exr"), sio.read("images/pool/pool-60s-full.exr"), ], crops=[ Cropbox(top=100, left=200, height=96, width=128, scale=5), Cropbox(top=100, left=450, height=96, width=128, scale=5), ], scene_name="Pool", method_names=[ "Reference", "Path Tracer", "UPS+MCMC", "Radiance-based", "Ours" ]) figuregen.figure([figure.figure_row], width_cm=17.7, filename="pool_with_template.pdf") try: from figuregen.util import jupyter jupyter.convert('pool_with_template.pdf', 300) except: print('Warning: pdf could not be converted to png')
placeholder.set_title("top", "(a) Scene layout") # define the layout renderings.layout.set_col_titles("bottom", 2.8, offset_mm=0.5, fontsize=8) renderings.layout.set_padding(right=2.0, column=0.5) if title: renderings.layout.set_col_titles("top", 2.8, fontsize=8, offset_mm=0.0) renderings.layout.set_title("top", 2.8, fontsize=8, offset_mm=0.5) # align all other modules weights.copy_layout(renderings) cbar.copy_layout(renderings) techs_grid.copy_layout(renderings) placeholder.copy_layout(renderings) # Add extra paddings weights.layout.set_padding(right=0.5) cbar.layout.set_padding(right=4) if add_placeholder: return [placeholder, techs_grid, renderings, weights, cbar] else: return [techs_grid, renderings, weights, cbar] if __name__ == "__main__": top_frame = FrameData(14) bot_frame = FrameData(50) rows = [make_figure(top_frame), make_figure(bot_frame, False)] figuregen.figure(rows, 17.7, "Figure3.pdf", tex_packages=["{dfadobe}"])
def make_plot(): rs = [1.0 / 100.0, 1.0 / 10.0, 0.5, 1, 2, 10, 100] data = [] names = [] for config in scene_configs: method_images = [ simpleimageio.read( os.path.join(config["scene_folder"], folder, "render.exr")) for _, folder in methods ] reference_image = simpleimageio.read( os.path.join(config["scene_folder"], "reference.exr"))[:, :, :3] scene_err = [ util.image.relative_mse_outlier_rejection(m, reference_image, 0.01) for m in method_images ] speedups = [err / scene_err[-1] for err in scene_err] speedups.pop() data.append([rs, speedups]) names.append(config["scene_name"]) plot = figuregen.PgfLinePlot(aspect_ratio=0.6, data=data) plot.set_padding(3.5, 5) plot.set_axis_label('x', "Radius scale") plot.set_axis_label('y', "Error") colors = [ [232, 181, 88], [5, 142, 78], [94, 163, 188], [181, 63, 106], [126, 83, 172], [37, 85, 166], ] plot.set_colors(colors) plot.set_font(8, tex_package="{dfadobe}") plot.set_linewidth(1.5) plot.set_axis_properties('x', ticks=[1.0 / 100.0, 1.0 / 10.0, 0.5, 1, 2, 10]) plot.set_axis_properties('y', ticks=[0.1, 0.5, 1.0], use_log_scale=False, range=[0.1, 1.2]) plot.set_v_line(pos=1, color=[0, 0, 0], linestyle=(4, 6), linewidth_pt=0.6) plot_module = figuregen.Grid(1, 1) plot_module.get_element(0, 0).set_image(plot) reference_grid = figuregen.Grid(num_rows=2, num_cols=3) for i in range(6): e = reference_grid.get_element(int(i / 3), i % 3) img = simpleimageio.read( os.path.join(scene_configs[i]["scene_folder"], "reference.exr"))[:, :, :3] tm = tonemap(img, scene_configs[i]["exposure"]) e.set_image(tm) e.set_caption(scene_configs[i]["scene_name"]) e.set_frame(3, colors[i]) l = reference_grid.get_layout() l.set_caption(2.8, fontsize=8, offset_mm=0.5) l.set_padding(left=1) figuregen.figure([[plot_module, reference_grid]], 17.7, "Results/RadiusFigure.pdf", tex_packages=["{dfadobe}"])
for sub_fig in bottom_grids: for col in range(bottom_cols): method = method_filenames[sub_fig_idx] image = get_image(method, crops[col]) e = sub_fig.get_element(0, col).set_image(figuregen.PNG(image)) e.set_frame(linewidth=0.8, color=crop_colors[col]) if sub_fig_idx != 0: # Method rmse = get_error(method, crops[col]) place_label(e, txt=rmse) sub_fig_idx += 1 # Specify paddings (unit: mm) for sub_fig in bottom_grids: sub_fig.get_layout().set_padding(column=0.5, right=1.0, row=0.5) bottom_grids[-1].get_layout().set_padding(right=0.0) # remove last padding # ---------- V-STACK of Horizontal Figures (create figure) ---------- v_grids = [[top_grid], bottom_grids] if __name__ == "__main__": figuregen.figure(v_grids, width_cm=18., filename='vertical-stack.pdf') figuregen.figure(v_grids, width_cm=18., filename='vertical-stack.pptx') figuregen.figure(v_grids, width_cm=18., filename='vertical-stack.html') try: from figuregen.util import jupyter jupyter.convert('vertical-stack.pdf', 300) except: print('Warning: pdf could not be converted to png')