variationist.visualization package
Submodules
variationist.visualization.altair_chart module
- class variationist.visualization.altair_chart.AltairChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, zoomable: bool | None = True)[source]
Bases:
ChartA base class for building an alt.Chart chart object.
- add_dropdown_components(base_chart: Chart, tooltip: list[altair.vegalite.v5.schema.channels.Tooltip], dropdown_keys: list[str], dropdown_elements: list[list[str]], color: Color, operation: str) Chart[source]
A function that creates dropdown components and adds them to the chart.
- Parameters:
base_chart (alt.Chart) – The base chart object in which to add the dropdown components.
tooltip (list[alt.Tooltip]) – A list of alt.Tooltip objects.
dropdown_keys (list[str]) – A list of keys corresponding to each dropdown.
dropdown_elements (list[str[str]]) – A list of lists, each containing the values for each dropdown (1:1 with dropdown_keys).
color (alt.Color) – The alt.Color dimension to be filtered in the chart.
operation (str) – Whether the operation based on color is “fill”, “color”, or “opacity”.
- Returns:
base_chart – The same base chart object with the dropdown components added.
- Return type:
alt.Chart
- add_search_component(base_chart: Chart, tooltip: list[altair.vegalite.v5.schema.channels.Tooltip], dim: Color | Y) Chart[source]
A function that creates a search component and adds it to the chart.
- Parameters:
base_chart (alt.Chart) – The base chart object in which to add the search component.
tooltip (list[alt.Tooltip]) – A list of alt.Tooltip objects.
dim (Union[alt.Color, alt.Y]) – The alt.Color or alt.Y dimension to be filtered in the chart.
- Returns:
base_chart – The same base chart object with the search component added.
- Return type:
alt.Chart
- create_base_chart(df_data: DataFrame) Chart[source]
A function that creates a base alt.Chart chart for the given data.
- Parameters:
df_data (pd.core.frame.DataFrame) – A long-form dataframe storing the results of a prior analysis for a given metric that will be used for visualization purposes.
- Returns:
base_chart – A base alt.Chart chart object.
- Return type:
alt.Chart
- get_dim(dim: int | str, chart_dims: dict) -> (<class 'str'>, <class 'str'>)[source]
A function that returns the name and (altair) type of a variable given a chart dimension and the previously stored variable names, types, and semantics.
- Parameters:
dim (Union[int, str]) – The dimension of interest (e.g., “x”, “y”, “lat”, “lon”, “color”, etc).
chart_dims (dict) – The mapping dictionary for the variables of the given chart.
- Returns:
var_name (str) – The variable name referring to the dimension of interest.
var_type_ (str) – The (altair) variable type referring to the dimension of interest.
- save(output_folder: str, chart_name: str, output_formats: list[str] | None = ['html']) None[source]
A function that saves the chart to a subfolder (with name matching the metric) of the output folder in various formats.
- Parameters:
output_folder (str) – A path to the output folder in which to save the chart.
chart_name (str) – A name representing the chart object to be saved.
output_formats (Optional[list[str]] = ["html"]) – A list of output formats for the charts. By default, only the interactive HTML chart is saved, i.e., [“html”]. Extra choices: [“pdf”, “svg”, “png”]. Note that for very large datasets the extra choices are too heavy to build.
variationist.visualization.bar_chart module
- class variationist.visualization.bar_chart.BarChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None)[source]
Bases:
AltairChartA class for building a BarChart object.
variationist.visualization.binned_geo_chart module
- class variationist.visualization.binned_geo_chart.BinnedGeoChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None, shapefile_path: str | None = None)[source]
Bases:
AltairChartA class for building a BinnedGeoChart object.
variationist.visualization.chart module
variationist.visualization.chart_utils module
variationist.visualization.choropleth_chart module
- class variationist.visualization.choropleth_chart.ChoroplethChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None)[source]
Bases:
AltairChartA class for building a ChoroplethChart object.
variationist.visualization.density_geo_chart module
- class variationist.visualization.density_geo_chart.DensityGeoChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None)[source]
Bases:
PlotlyChartA class for building a DensityGeoChart object.
variationist.visualization.diversity_bar_chart module
- class variationist.visualization.diversity_bar_chart.DiversityBarChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None)[source]
Bases:
AltairChartA class for building a BarChart object for lexical diversity metrics.
variationist.visualization.heatmap_chart module
- class variationist.visualization.heatmap_chart.HeatmapChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None)[source]
Bases:
AltairChartA class for building a HeatmapChart object.
variationist.visualization.line_chart module
- class variationist.visualization.line_chart.LineChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None)[source]
Bases:
AltairChartA class for building a LineChart object.
variationist.visualization.plotly_chart module
- class variationist.visualization.plotly_chart.PlotlyChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, zoomable: bool | None = True)[source]
Bases:
ChartA base class for building a plotly.graph_objs._figure.Figure chart object.
- add_dropdown_components(base_chart, dropdown_elements: list[list[str]])[source]
A function that creates dropdown components and adds them to the chart.
- Parameters:
base_chart (alt.Chart) – The base chart object in which to add the dropdown components.
dropdown_elements (list[list[str]]) – A list of lists, each containing the values for each dropdown (1:1 with dropdown_keys).
- Returns:
base_chart – The same base chart object with the dropdown components added.
- Return type:
alt.Chart
- create_base_chart(df_data: DataFrame)[source]
A function that creates a base plotly.graph_objs._figure.Figure chart for the given data.
- Parameters:
df_data (pd.core.frame.DataFrame) – A long-form dataframe storing the results of a prior analysis for a given metric that will be used for visualization purposes.
- Returns:
base_chart – A base plotly.graph_objs._figure.Figure chart object.
- Return type:
plotly.graph_objs._figure.Figure
- save(output_folder: str, chart_name: str, output_formats: list[str] | None = ['html']) None[source]
A function that saves the chart to a subfolder (with name matching the metric) of the output folder in various formats.
- Parameters:
output_folder (str) – A path to the output folder in which to save the chart.
chart_name (str) – A name representing the chart object to be saved.
output_formats (Optional[list[str]] = ["html"]) – A list of output formats for the charts. By default, only the interactive HTML chart is saved, i.e., [“html”]. Extra choices: [“pdf”, “svg”, “png”]. Note that for very large datasets the extra choices are too heavy to build.
variationist.visualization.scatter_chart module
- class variationist.visualization.scatter_chart.ScatterChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None)[source]
Bases:
AltairChartA class for building a ScatterChart object.
variationist.visualization.scatter_geo_chart module
- class variationist.visualization.scatter_geo_chart.ScatterGeoChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None, shapefile_path: str | None = None)[source]
Bases:
AltairChartA class for building a ScatterGeoChart object.
variationist.visualization.stats_bar_chart module
- class variationist.visualization.stats_bar_chart.StatsBarChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None)[source]
Bases:
AltairChartA class for building a BarChart object for basic stats.
variationist.visualization.temporal_line_chart module
- class variationist.visualization.temporal_line_chart.TemporalLineChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None)[source]
Bases:
AltairChartA class for building a TemporalLineChart object.
variationist.visualization.text_only_bar_chart module
- class variationist.visualization.text_only_bar_chart.TextOnlyBarChart(df_data: DataFrame, chart_metric: str, metadata: dict, extra_args: dict = {}, chart_dims: dict = {}, zoomable: bool | None = True, top_per_class_ngrams: int | None = None)[source]
Bases:
AltairChartA class for building a BarChart object for text-only computations.