Learn R Programming

contentanalysis (version 0.2.1)

plot_word_distribution: Create interactive word distribution plot

Description

Creates an interactive plotly visualization of word frequencies across document segments or sections.

Usage

plot_word_distribution(
  word_distribution_data,
  plot_type = "line",
  smooth = FALSE,
  show_points = TRUE,
  colors = NULL
)

Value

A plotly object with interactive visualization.

Arguments

word_distribution_data

Tibble from calculate_word_distribution()

plot_type

Character. "line" or "area" (default: "line").

smooth

Logical. Apply smoothing to lines (default: FALSE).

show_points

Logical. Show data points on lines (default: TRUE).

colors

Character vector. Custom colors for words (optional).

Details

The plot shows:

  • X-axis: Document sections or segments

  • Y-axis: Relative frequency (percentage)

  • Each word as a separate line/area

  • Hover information with exact values

Examples

Run this code
if (FALSE) {
dist <- calculate_word_distribution(doc, c("method", "result", "conclusion"))
plot_word_distribution(dist, plot_type = "line", show_points = TRUE)

# Area plot with custom colors
plot_word_distribution(dist, plot_type = "area",
                      colors = c("#FF6B6B", "#4ECDC4", "#45B7D1"))
}

Run the code above in your browser using DataLab