Module functions.graphy.main_presentation

Functions

def add_combined_graphs_slide(info: dict, figures: list, title_text: str, subtitle_text: str, tag_text: str, group_images: bool = True, share_y_labels: bool = True) ‑> None

combines a list of plotly figures onto a grid and saves it as a powerpoint slied

Args

info : dict
The presentation object
figures : list
list of plotly figures, make sure to use single instances of them, in doubt make a deepcopy
title_text : str
title_text
subtitle_text : str
subtitle_text
tag_text : str
tag_text
group_images : bool, optional
determines whether images are grouped in the slide. Defaults to True.
share_y_labels : bool, optional
determines whether images share the y axis labels row-wise. Defaults to True.

Raises

ValueError
if an invalid number of figures is entered, only 2 to 9 figures are valid
def add_graph_slide(info: dict, position_1_text: str, position_2_text: str, position_3_text: str) ‑> None
def add_table_slide(info: dict, title_text: str, table: pandas.core.frame.DataFrame, table_width: float = 22.5, table_height: float = 5.0, table_top_distance: float = 4.5, table_left_distance: float = 1.5, column_titles: Optional[None] = None, column_alignments: Optional[None] = None, column_widths: Optional[None] = None, bold_cells: Optional[None] = None, font_size: int = 14, row_heights: Optional[None] = None, cells_with_custom_color: Optional[None] = None, show_table_background_color: bool = True, title_font_size: int = 20, table_font_name: str = 'Leelawadee UI', cells_with_hyperlinks: Optional[None] = None) ‑> None

Adds a table slide to the presentation

Args

info : dict
The presentation object
title_text : str
The title of the slide
table : pd.DataFrame
The table that should be added to the slide
table_width : float, optional
The width of the table. Defaults to 22.5.
table_height : float, optional
The height of the table. Defaults to 5.0.
column_alignments : Union[None, list[str]], optional
The alignment of the columns. Defaults to None. If None, all columns will be aligned left. If a list is passed, it should contain the alignment for each column in the table. The alignment can be 1 (left), 2 (center), or 3 (right).
column_titles : Union[None, list[str]], optional
The titles of the columns. Defaults to None. If None, the table will not have column titles. If a list is passed, it should contain the title for each column in the table.
column_widths : Union[None, list[int]], optional
The width of the columns. Defaults to None. If None, all columns will have the same width. If a list is passed, it should contain the width for each column in the table. The values should be integers and only the relative width is important.
bold_cells : Union[None, list[tuple[int, int]]], optional
The cells that should be bold. Defaults to None. If None, no cells will be bold. If a list is passed, it should contain the row and column index of the cells that should be bold.
font_size : int, optional
The font size of the text in the table. Defaults to 14.
row_heights : Union[None, list[float]], optional
The height of the rows. Defaults to None. If None, all rows will have the automatic height. If a list is passed, it should contain the height for each row in the table.
cells_with_custom_color : Union[None, dict], optional
The cells that should have a custom color. Defaults to None. If None, no cells will have a custom color. If a dictionary is passed, it should contain the row and column index of the cells as keys and the color as values. The color should be a string with the hex code of the color.
show_table_background_color : bool, optional
Determines if the table background color should be shown. Defaults to True.
title_font_size : int, optional
The font size of the title. Defaults to 20.
table_font_name : str, optional
The name of the font used in the whole table.
cells_with_hyperlinks : Union[None, dict], optional
The cells that should have a hyperlink. Defaults to None. If None, no cells will have a hyperlink. If a dictionary is passed, it should contain the row and column index of the cells as keys and the hyperlink as values. The hyperlink should be a string with the address of the hyperlink.
def add_text_slide(info: dict, text: Union[list[dict], list[str]], my_title: str = 'gfs-zürich, Markt- & Sozialforschung', vertical_alignment: str = 'top') ‑> None

Adds a text slide to the presentation

Args

info : dict
The presentation object
text : Union[list[dict], list[str]]
The text that should be added to the slide. If a list of dictionaries is passed, each dictionary should contain a "text" key with the text that should be added to the slide. Additionally, the dictionary can contain a "size" key with the font size of the text, a "bold" key with a boolean value that determines if the text should be bold, a "hyperlink" key that adds a link as the value, a "alignment" key that changes the text alignment (left, center, right) and a "color" key with the color of the text. If a list of strings is passed, each string will be added to the slide as a paragraph.
my_title : str, optional
The title of the slide. Defaults to 'gfs-zürich, Markt- & Sozialforschung'.
vertical_alignment : str, optional
The vertical alignment of the text. Defaults to 'top'.
def add_to_graph_list(info: dict, position_1_text: str, position_2_text: str, position_3_text: str) ‑> None
def delete_all_files_in_folder(folder: str, file_type: str) ‑> None
def export_figure(info: dict, fig: plotly.graph_objs._figure.Figure) ‑> None
def save_presentation(info: dict) ‑> None

Saves the presentation

Args

info : dict
The presentation object
def show_param_as_title(param, i, param_2='', j='')
def start_presentation(name: str, df: pandas.core.frame.DataFrame, meta: pyreadstat._readstat_parser.metadata_container, output_path: str = './output/', template_path: str = './templates/', template_custom: str = 'auto', color_theme: str = 'standard', language: str = 'de', value_labels_color: int = 130, weight: str = '', line_width_linechart: int = 4, line_marker_size_linechart: int = 8, bar_width_barchart: float = 0.7, bar_width_stacked_barchart: float = 0.8, bar_gap_barchart: float = 0.15, break_distance: float = 0.5, count_name: str = 'N', logo_side: str = 'right', project_leader: str = None, project_people: list[str] = None, export_svg: bool = False, standard_arguments: dict = None, show_page_number: bool = False, use_wide_screen: bool = False) ‑> dict

Creates a new presentation

Args

name : str
Changes the name of the presentation
df : pd.DataFrame
The current data file ~ usually df
meta : pyreadstat._readstat_parser.metadata_container
The current meta data file ~ usually meta
output_path : str, optional
Changes path and name of the output files. Defaults to "./output/".
template_path : str, optional
Sets path of pptx-template file. Defaults to './templates/'.
template_custom : str, optional
Choose a custom template. Defaults to 'auto'.
color_theme : str, optional
Sets color theme for graph. ~ 'test', 'gfs'. Defaults to 'standard'.
language : str, optional
Sets language for texts like subtitle and tag. ~ 'fr', 'en', 'it'. Defaults to 'de'.
value_labels_color : int, optional
Sets threshold for black or white label color. Use 0 for all black labels and 255 for all white. Use numbers between for a mix. Defaults to 130.
weight : str, optional
Turns weight on if weight variable name is added. ~ "gewicht". Defaults to ''.
bar_width_barchart : float, optional
Sets the width of the barchart bars. Defaults to 0.7.
bar_width_stacked_barchart : float, optional
Sets the width of the stacked barchart bars. Defaults to 0.8.
bar_gap_barchart : float, optional
Sets the gap between the bars within a group. Defaults to 0.15.
break_distance : float, optional
Sets the distance between the breaks. Defaults to 0.5.
count_name : str, optional
Changes the name of the count. ~ if "K" is passed in, counts look like "K = 42". Defaults to 'N'.
logo_side : str, optional
Changes the position of the logo on the presentation slides. ~ 'left'. Defaults to 'right'.
project_leader : str
The first name of the project leader. Can be "Andreas" for example. Defaults to None.
project_people : list[str], optional
A list of the names of the people working on the project. For example ["Andreas", "Nadia"]. Defaults to None.
export_svg : bool, optional
Exports graphs as .svg files if True. Defaults to False.
standard_arguments : dict, optional
Adds some standard arguments that normally don't need to be changed. Defaults to {}.
show_page_number : bool, optional
Turns page number on PowerPoint on and off ~ True. Defaults to False.
use_wide_screen : bool, optional
Turns slides into 16:9 widescreen format ~ True. Defaults to False.

Returns

dict
Returns a dictionary with presentation info, the presentation object and some info about the plot theme.