GitMA Vizualize#
Note
All vizualization methods in this module are integrated in the CatmaProject
class and the AnnotationCollection
class.
- duplicate_generator(df, property_col)#
Yields for each value in property col a copy of the given data frame row.
- Parameters
df (pd.DataFrame) – Annotation collection as data frame.
property_col (str) – The property’s name.
- Yields
Generator[pd.Series, None, None] – The data frame row
- duplicate_rows(ac_df, property_col)#
Duplicates rows in AnnotationCollection DataFrame if multiple property values exist in defined porperty column.
- Parameters
ac_df (pd.DataFrame) – Annotation collection data frame.
property_col (str) – The property name with the prefix ‘prop:’.
- Raises
ValueError – If the property does not exist in the annotation collection.
- Returns
The new dataframe with duplicated rows.
- Return type
pd.DataFrame
- get_color_dict(annotation_df, color_col, colors=None)#
- update_figure(fig)#
Default plotly template for GitMA.
- Parameters
fig (go.Figure) – The figure to be updated.
- Returns
The updated figure.
- Return type
go.Figure
- format_annotation_text(text)#
Format the text of an annotation for plotting.
- Parameters
text (str) – Annotation string.
- Returns
html formatted string.
- Return type
str
- plot_annotations(ac, y_axis='tag', color_prop='tag')#
Creates interactive Plotly Scatter Plot to a explore a annotation collection.
- Parameters
ac (AnnotationCollection) – gitma.AnnotationCollection
y_axis (str, optional) – The columns in AnnotationCollection DataFrame used for y axis. Defaults to ‘tag’.
color_prop (str, optional) – A Property’s name used in the AnnotationCollection . Defaults to None.
- Returns
Plotly scatter plot.
- Return type
go.Figure
- plot_annotation_progression(project)#
Plot the annotation progression for every annotator in a CATMA project.
- Parameters
project (CatmaProject) – The plotted CATMA project.
- Returns
Plotly scatter plot.
- Return type
go.Figure
- plot_scaled_annotations(ac, tag_scale=None, bin_size=50, smoothing_window=100)#
Plots a graph with scaled annotations. This function is still under development.
- Parameters
ac (AnnotationCollection) – A CATMA
tag_scale (dict, optional) – description. Defaults to None.
bin_size (int, optional) – description. Defaults to 50.
smoothing_window (int, optional) – description. Defaults to 100.
- Raises
Exception – description
- plot_interactive(catma_project, color_col='annotation collection')#
This function generates one Plotly scatter plot per annotated document in a CATMA project. By default the colors represent the annotation collections. By that they can’t be deactivated with the interactive legend.
- Parameters
catma_project (CatmaProject) – The plotted project.
color_col (str, optional) – ‘annotation collection’, ‘annotator’, ‘tag’ or any property with the prefix ‘prop:’. Defaults to ‘annotation collection’.
- Returns
Plotly scatter plot.
- Return type
go.Figure
- compare_annotation_collections(catma_project, annotation_collections, color_col='tag')#
Plots annotations of multiple annotation collections of the same texts as line plot.
- Parameters
catma_project (CatmaProject) – description
annotation_collections (list) – A list of annotation collection names.
color_col (str, optional) – Either ‘tag’ or one property name with prefix ‘prop:’. Defaults to ‘tag’.
- Raises
ValueError – If one of the annotation collection’s names does not exist.
- Returns
Plotly Line Plot.
- Return type
go.Figure