Plot the results of a fitted scaling model, from (e.g.) a predicted textmodel_wordscores model or a fitted textmodel_wordfish or textmodel_ca model. Either document or feature parameters may be plotted: an ideal point-style plot (estimated document position plus confidence interval on the x-axis, document labels on the y-axis) with optional renaming and sorting, or as a plot of estimated feature-level parameters (estimated feature positions on the x-axis, and a measure of relative frequency or influence on the y-axis, with feature names replacing plotting points with some being chosen by the user to be highlighted).

textplot_scale1d(x, margin = c("documents", "features"), doclabels = NULL,
  sort = TRUE, groups = NULL, highlighted = NULL, alpha = 0.7,
  highlighted_color = "black")



the fitted or predicted scaling model object to be plotted


"documents" to plot estimated document scores (the default) or "features" to plot estimated feature scores by a measure of relative frequency


a vector of names for document; if left NULL (the default), docnames will be used


if TRUE (the default), order points from low to high score. If a vector, order according to these values from low to high. Only applies when margin = "documents".


either: a character vector containing the names of document variables to be used for grouping; or a factor or object that can be coerced into a factor equal in length or rows to the number of documents. See groups for details.


a vector of feature names to draw attention to in a feature plot; only applies if margin = "features"


A number between 0 and 1 (default 0.5) representing the level of alpha transparency used to overplot feature names in a feature plot; only applies if margin = "features"


color for highlighted terms in highlighted


a ggplot2 object


The groups argument only applies when margin = "documents".

See also


ie_dfm <- dfm(data_corpus_irishbudget2010)
doclab <- apply(docvars(data_corpus_irishbudget2010, c("name", "party")),
                1, paste, collapse = " ")

## wordscores
refscores <- c(rep(NA, 4), 1, -1, rep(NA, 8))
ws <- textmodel_wordscores(ie_dfm, refscores, smooth = 1)
# plot estimated word positions
textplot_scale1d(ws, highlighted = c("minister", "have", "our", "budget"))
# plot estimated document positions
textplot_scale1d(predict(ws), doclabels = doclab,
                 groups = docvars(data_corpus_irishbudget2010, "party"))

## wordfish
wf <- textmodel_wordfish(dfm(data_corpus_irishbudget2010), dir = c(6,5))
# plot estimated document positions
textplot_scale1d(wf, doclabels = doclab)
textplot_scale1d(wf, doclabels = doclab,
                 groups = docvars(data_corpus_irishbudget2010, "party"))
# plot estimated word positions
textplot_scale1d(wf, margin = "features",
                 highlighted = c("government", "global", "children",
                                 "bank", "economy", "the", "citizenship",
                                 "productivity", "deficit"))

## correspondence analysis
ca <- textmodel_ca(ie_dfm)
# plot estimated document positions
textplot_scale1d(ca, margin = "documents",
                 doclabels = doclab,
                 groups = docvars(data_corpus_irishbudget2010, "party"))
# }