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 visualizationsysights.viz.recommendations: Recommendation system visualizations
Functions
Plot the distribution of comments per post. |
|
Plot the distribution of posts, articles, shares, and comments per user. |
|
Plot the distribution of posts, articles, shares, and comments per day. |
|
|
Plot the distribution of reactions per day. |
|
Plot the top trending topics over time. |
|
Plot the top trending hashtags over time. |
|
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 operationssmooth_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 operationslimit – 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 operationslimit – 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 operationslimit – 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.