ySights

Tutorials

  • Tutorials
    • Getting Started with ySights
      • What You’ll Learn
      • Prerequisites
      • 1. Importing ySights
      • 2. Initializing the Data Handler
      • 3. Exploring the Simulation
      • 4. Working with Agents
        • Filtering Agents by Feature
        • Age Distribution Visualization
      • 5. Working with Posts
      • 6. Agent Interest Profiles
        • Visualizing Interest Profile
      • 7. Custom Queries
      • Summary
      • Next Steps
    • Network Analysis with ySights
      • What You’ll Learn
      • 1. Extracting the Social Network
        • Network Density
      • 2. Degree Distribution Analysis
      • 3. Centrality Measures
        • Degree Centrality
        • Betweenness Centrality
      • 4. Mention Network
      • 5. Ego Networks
        • Visualizing an Ego Network
      • 6. Community Detection
      • 7. Network Comparison
      • Summary
      • Next Steps
    • Algorithms in ySights
      • What You’ll Learn
      • 1. Profile Similarity Analysis
      • 2. Recommendation System Metrics
        • Engagement Momentum
        • Personalization Balance Score
      • Summary
      • Next Steps
    • Visualization with ySights
      • What You’ll Learn
      • 1. Global Trends Visualization
        • Daily Content Trends
        • Daily Reactions Trends
        • Content per User Distribution
        • Trending Hashtags
        • Trending Emotions
        • Trending Topics
        • Comments Distribution
      • 2. Topic Visualization
        • Topic Density Temporal Evolution
      • 3. Profile Similarity Visualization
        • Profile Similarity Distribution
        • Similarity vs. Network Degree
        • Binned Similarity per Degree
      • 4. Recommendation System Visualization
        • Recommendations per Post
        • Recommendations vs. Reactions
        • Recommendations vs. Comments
      • 5. Saving Visualizations
      • Summary
      • Best Practices
      • Next Steps
    • Overview
    • Getting Started
    • Tutorial Contents
      • 1. Getting Started with ySights
      • 2. Network Analysis
      • 3. Algorithms
      • 4. Visualization
    • Learning Path
    • Tips for Success
    • Next Steps
    • Resources

Module Documentation

  • Models Package
    • YDataHandler
    • Agent Classes
    • Post Classes
  • Algorithms Package
    • Profile Analysis
      • Agent Profile Analysis
    • Recommender Metrics
      • Recommender System Metrics
    • Topic Analysis
      • Topic Analysis Algorithms
  • Visualization Package
    • Global Trends
      • Global Trends Visualization Functions
    • Topic Visualizations
      • Topic Visualization Functions
    • Profile Visualizations
      • Profile Visualization Functions
    • Recommendation Visualizations
      • Recommendation System Visualization Functions
ySights
  • ysights.viz.global_trends
  • View page source

ysights.viz.global_trends

Global Trends Visualization Functions

This module provides visualization functions for aggregate statistics and trends across the entire YSocial simulation. It includes functions for analyzing content creation, user activity, reactions, hashtags, emotions, topics, and engagement patterns over time.

Functions:
  • daily_contents_trends: Posts, articles, shares, and comments per day

  • contents_per_user_distributions: Distribution of content creation per user

  • daily_reactions_trends: Reactions distribution over time

  • trending_hashtags: Most popular hashtags

  • trending_emotions: Most expressed emotions

  • tending_topics: Most discussed topics

  • comments_per_post_distribution: Distribution of comment counts

Example

Visualizing global trends:

from ysights import YDataHandler
from ysights.viz import (
    daily_contents_trends,
    contents_per_user_distributions,
    trending_hashtags,
    trending_emotions
)

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

# Daily content trends
fig = daily_contents_trends(ydh)
fig.suptitle('Content Production Over Time')
fig.show()

# Content distribution per user
fig = contents_per_user_distributions(ydh)
fig.show()

# Top 10 trending hashtags
fig = trending_hashtags(ydh, top_n=10)
fig.show()

# Emotion distribution
fig = trending_emotions(ydh)
fig.show()

See also

  • ysights.viz.topics_viz: Topic-specific visualizations

  • ysights.viz.recommendations: Recommendation system visualizations

Functions

comments_per_post_distribution(YDH)

Plot the distribution of comments per post.

contents_per_user_distributions(YDH)

Plot the distribution of posts, articles, shares, and comments per user.

daily_contents_trends(YDH)

Plot the distribution of posts, articles, shares, and comments per day.

daily_reactions_trends(YDH[, smooth_days])

Plot the distribution of reactions per day.

tending_topics(YDH[, limit, leaning])

Plot the top trending topics over time.

trending_emotions(YDH[, limit, leaning])

Plot the top trending hashtags over time.

trending_hashtags(YDH[, limit, leaning])

Plot the top trending hashtags over time.

ysights.viz.global_trends.daily_contents_trends(YDH)[source]

Plot the distribution of posts, articles, shares, and comments per day. This function retrieves the count of posts, articles, shares, and comments from the database, grouped by day, and plots them on a single graph.

Parameters:

YDH (YDataHandler) – YDataHandler instance for database operations

Returns:

A matplotlib figure object containing the plot of daily content distributions.

ysights.viz.global_trends.daily_reactions_trends(YDH, smooth_days=None)[source]

Plot the distribution of reactions per day. This function retrieves the count of reactions from the database, grouped by day, and plots them on a single graph.

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

  • smooth_days – If specified, the data will be smoothed over this number of days.

Returns:

A matplotlib figure object containing the plot of daily reaction distributions.

ysights.viz.global_trends.contents_per_user_distributions(YDH)[source]

Plot the distribution of posts, articles, shares, and comments per user. This function retrieves the count of posts, articles, shares, and comments from the database, grouped by user, and plots them on a single graph.

Parameters:

YDH (YDataHandler) – YDataHandler instance for database operations

Returns:

A matplotlib figure object containing the plot of content distributions per user.

ysights.viz.global_trends.trending_hashtags(YDH, limit=10, leaning=None)[source]

Plot the top trending hashtags over time. This function retrieves the top trending hashtags from the database, grouped by day, and plots them on a single graph.

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

  • limit – The number of top trending hashtags to plot

  • leaning – Optional parameter to filter hashtags by user leaning (e.g., ‘democrat’, ‘republican’). If None, all hashtags are considered.

Returns:

A matplotlib figure object containing the plot of trending hashtags.

ysights.viz.global_trends.trending_emotions(YDH, limit=10, leaning=None)[source]

Plot the top trending hashtags over time. This function retrieves the top trending hashtags from the database, grouped by day, and plots them on a single graph.

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

  • limit – The number of top trending hashtags to plot

  • leaning – Optional parameter to filter hashtags by user leaning (e.g., ‘democrat’, ‘republican’). If None, all hashtags are considered.

Returns:

A matplotlib figure object containing the plot of trending hashtags.

ysights.viz.global_trends.tending_topics(YDH, limit=10, leaning=None)[source]

Plot the top trending topics over time. This function retrieves the top trending topics from the database, grouped by day, and plots them on a single graph.

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

  • limit – The number of top trending topics to plot

  • leaning – Optional parameter to filter topics by user leaning (e.g., ‘democrat’, ‘republican’). If None, all topics are considered.

Returns:

A matplotlib figure object containing the plot of trending topics.

ysights.viz.global_trends.comments_per_post_distribution(YDH)[source]

Plot the distribution of comments per post. This function retrieves the count of comments for each post from the database, and plots the distribution on a histogram.

Parameters:

YDH (YDataHandler) – YDataHandler instance for database operations

Returns:

A matplotlib figure object containing the histogram of comments per post.


© Copyright 2025, Giulio Rossetti.

Built with Sphinx using a theme provided by Read the Docs.