Skip to content

gravitools.report

Base functionality for PDF data reports

PDF(*, logo=None, **kwargs)

Bases: FPDF

PDF document customized for data reports

Extends the methods of fpdf.FPDF with common report methods and default settings.

Parameters:

  • logo (str, default: None ) –

    Path to a logo image to include in the page header.

line_height property

Calculated text line height

set_text_font()

Set default font size

header()

Create header section on current page

footer()

Create footer section on current page

horizontal_rule(y)

Create a horizontal divider line

section(text, add_page=True)

Create a section header

subsection(text, add_page=False)

Create a sub-section header

make_title(title, super_title=None)

Create the report title

Parameters:

  • title (str) –

    The report title text.

  • super_title (str, default: None ) –

    A smaller title above the main title, intended to state the report type.

insert_mpl_plot()

Insert the current Matplotlib plot

Report(*, author=None, logo=None, date=None)

Abstract base class for data reports

Parameters:

  • author (str, default: None ) –

    Report author.

body()

Create report contents

make()

Build the entire report

save(path)

Create report and save to file

Parameters:

  • path (str | Path) –

    Output path.

title(title, super_title=None)

Create the title

section(heading)

Create a new section

subsection(heading)

Create a new sub-section

text(text)

Write a simple line of text

plot_context()

Context manager to insert a Matplotlib figure

table(widths=None, aligns=None)

Context manager to create a table

Parameters:

  • widths (list[float], default: None ) –

    Column widths.

  • aligns (list[str], default: None ) –

    Column alignments.

row(*cell_texts)

Create a table row

plot(func)

Decorator marking report class methods as plots