Creates a horizontal bar plot showing log odds ratios for comparing word usage between categories. Positive values indicate higher usage in the first category, negative in the second.
Usage
plot_log_odds_ratio(
log_odds_data,
top_n = 10,
facet_by = NULL,
color_positive = "#10B981",
color_negative = "#EF4444",
height = 600,
width = NULL,
title = "Log Odds Ratio Comparison"
)Arguments
- log_odds_data
Data frame from calculate_log_odds_ratio()
- top_n
Number of top terms to show per direction (default: 10)
- facet_by
Character, column name to facet by (e.g., "category1" for one_vs_rest comparisons). NULL for no faceting.
- color_positive
Color for positive log odds (default: "#10B981" green)
- color_negative
Color for negative log odds (default: "#EF4444" red)
- height
Plot height in pixels (default: 600)
- width
Plot width in pixels (default: NULL for auto)
- title
Plot title (default: "Log Odds Ratio Comparison")
See also
Other visualization:
apply_standard_plotly_layout(),
create_empty_plot_message(),
create_message_table(),
create_standard_ggplot_theme(),
get_dt_options(),
get_plotly_hover_config(),
get_sentiment_color(),
get_sentiment_colors(),
plot_cluster_terms(),
plot_cross_category_heatmap(),
plot_entity_frequencies(),
plot_lexical_dispersion(),
plot_mwe_frequency(),
plot_ngram_frequency(),
plot_pos_frequencies(),
plot_semantic_viz(),
plot_similarity_heatmap(),
plot_term_trends_continuous(),
plot_weighted_log_odds(),
plot_word_frequency()
Examples
if (FALSE) { # \dontrun{
log_odds <- calculate_log_odds_ratio(dfm, "category", comparison_mode = "binary")
plot_log_odds_ratio(log_odds, top_n = 15)
} # }
