larray.ReportSheet.add_graphs¶
-
ReportSheet.
add_graphs
(self, array_per_title, axis_per_loop_variable, template=None, width=None, height=None, graphs_per_row=1)[source]¶ Add multiple graph items to the current sheet. This method is mainly useful when multiple graphs are generated by iterating over one or several axes of an array (see examples below). The report Excel file is generated only when the
to_excel
is called.- Parameters
- array_per_title: dict
dictionary containing pairs (title template, array).
- axis_per_loop_variable: dict
dictionary containing pairs (variable used in the title template, axis).
- templatestr, optional
name of the template to be used to generate the graph. The full path to the template file must be provided if no template directory has not been set or if the template file belongs to another directory. Defaults to the defined template (see
set_graph_template
).- widthint, optional
width of the title item. The current default value is used if None (see
set_item_default_size
). Defaults to None.- heightint, optional
height of the title item. The current default value is used if None (see
set_item_default_size
). Defaults to None.- graphs_per_row: int, optional
Number of graphs per row. Defaults to 1.
Examples
>>> demo = load_example_data('demography_eurostat') >>> report = ExcelReport(EXAMPLE_EXCEL_TEMPLATES_DIR)
>>> sheet_pop = report.new_sheet('Population') >>> pop = demo.pop
Generate a new graph for each combination of gender and year
>>> sheet_pop.add_graphs({'Population of {gender} by country for the year {year}': pop}, ... {'gender': pop.gender, 'year': pop.time}, ... template='line', width=450, height=250, graphs_per_row=2)
>>> # do not forget to call 'to_excel' to create the report file >>> report.to_excel('Demography_Report.xlsx')