Skip to content

Plots

tinytopics.plot

plot_loss(losses, figsize=(10, 8), dpi=300, title='Loss curve', color_palette=None, output_file=None)

Plot the loss curve over training epochs.

Parameters:

Name Type Description Default
losses Sequence[float]

List of loss values for each epoch.

required
figsize Tuple[int, int]

Plot size. Default is (10, 8).

(10, 8)
dpi int

Plot resolution. Default is 300.

300
title str

Plot title. Default is "Loss curve".

'Loss curve'
color_palette Sequence[str] | str | None

Custom color palette.

None
output_file str | None

File path to save the plot. If None, displays the plot.

None

plot_structure(L_matrix, normalize_rows=False, figsize=(12, 6), dpi=300, title='Structure Plot', color_palette=None, output_file=None)

Structure plot for visualizing document-topic distributions.

Parameters:

Name Type Description Default
L_matrix ndarray

Document-topic distribution matrix.

required
normalize_rows bool

If True, normalizes each row of L_matrix to sum to 1.

False
figsize Tuple[int, int]

Plot size. Default is (12, 6).

(12, 6)
dpi int

Plot resolution. Default is 300.

300
title str

Plot title.

'Structure Plot'
color_palette Sequence[str] | str | None

Custom color palette.

None
output_file str | None

File path to save the plot. If None, displays the plot.

None

plot_top_terms(F_matrix, n_top_terms=10, term_names=None, figsize=(10, 8), dpi=300, title='Top Terms', color_palette=None, nrows=None, ncols=None, output_file=None)

Plot top terms for each topic in horizontal bar charts.

Parameters:

Name Type Description Default
F_matrix ndarray

Topic-term distribution matrix.

required
n_top_terms int

Number of top terms to display per topic. Default is 10.

10
term_names Sequence[str] | None

List of term names corresponding to indices.

None
figsize Tuple[int, int]

Plot size. Default is (10, 8).

(10, 8)
dpi int

Plot resolution. Default is 300.

300
title str

Plot title.

'Top Terms'
color_palette Sequence[str] | str | None

Custom color palette.

None
nrows int | None

Number of rows in the subplot grid.

None
ncols int | None

Number of columns in the subplot grid.

None
output_file str | None

File path to save the plot. If None, displays the plot.

None