ysights.viz.topics_viz

Topic Visualization Functions

This module provides visualization functions for analyzing topic dynamics and evolution in YSocial simulations. It focuses on temporal patterns of interest and topic density across different user groups.

Functions:
  • topic_density_temporal_evolution: Visualize topic density over time as a heatmap

Example

Visualizing topic evolution:

from ysights import YDataHandler
from ysights.viz import topic_density_temporal_evolution

ydh = YDataHandler('path/to/database.db')

# Visualize all topics over time
fig = topic_density_temporal_evolution(ydh, min_days=15)
fig.show()

# Filter by user leaning
fig_left = topic_density_temporal_evolution(ydh, min_days=10, leaning='left')
fig_left.update_layout(title="Topics: Left-leaning Users")
fig_left.show()

See also

Functions

topic_density_temporal_evolution(YDH[, ...])

Visualize the temporal evolution of topic density in a heatmap format.

ysights.viz.topics_viz.topic_density_temporal_evolution(YDH, min_days=15, leaning=None)[source]

Visualize the temporal evolution of topic density in a heatmap format. This function retrieves user interest data, aggregates it by interest and day, and generates a heatmap

Parameters:
  • YDH (YDataHandler) – YDataHandler instance for database operations

  • min_days – Minimum number of days an interest must be present to be included in the heatmap

  • leaning (str) – Optional parameter to filter interests by user leaning (e.g., ‘democrats’, ‘republican’, etc.)

Returns:

A Plotly heatmap figure showing the density of topics over time