The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Type: Package
Title: Highlight Lines and Points in 'ggplot2'
Version: 0.5.0
Description: Make it easier to explore data with highlights.
License: MIT + file LICENSE
URL: https://yutannihilation.github.io/gghighlight/, https://github.com/yutannihilation/gghighlight
BugReports: https://github.com/yutannihilation/gghighlight/issues
Depends: ggplot2 (≥ 3.3.6), R (≥ 3.4.0)
Imports: dplyr (≥ 1.0.4), ggrepel, lifecycle, purrr, rlang, tibble, scales, grDevices
Suggests: geomtextpath, knitr, rmarkdown, sf, testthat, vdiffr (≥ 0.3.0)
VignetteBuilder: knitr
Encoding: UTF-8
RoxygenNote: 7.3.2
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2025-06-14 07:26:33 UTC; yutan
Author: Hiroaki Yutani ORCID iD [aut, cre]
Maintainer: Hiroaki Yutani <yutani.ini@gmail.com>
Repository: CRAN
Date/Publication: 2025-06-14 07:50:02 UTC

Highlight Lines and Points in 'ggplot2'

Description

Make it easier to explore data with highlights.

Author(s)

Maintainer: Hiroaki Yutani yutani.ini@gmail.com (ORCID)

See Also

Useful links:


Highlight Data With Predicate

Description

gghighlight() highlights (almost) any geoms according to the given predicates.

Usage

gghighlight(
  ...,
  n = NULL,
  max_highlight = 5L,
  unhighlighted_params = list(),
  use_group_by = NULL,
  use_direct_label = NULL,
  label_key = NULL,
  label_params = list(fill = "white"),
  keep_scales = FALSE,
  calculate_per_facet = FALSE,
  line_label_type = c("ggrepel_label", "ggrepel_text", "text_path", "label_path",
    "sec_axis"),
  unhighlighted_colour = NULL
)

Arguments

...

Expressions to filter data, which is passed to dplyr::filter().

n

Number of layers to clone.

max_highlight

Max number of series to highlight.

unhighlighted_params

Aesthetics (e.g. colour, fill, and size) for unhighlighted geoms. Specifying colour = NULL or fill = NULL will preserve the original colour.

use_group_by

If TRUE, use dplyr::group_by() to evaluate predicate.

use_direct_label

If TRUE, add labels directly on the plot instead of using a legend.

label_key

Column name for label aesthetics.

label_params

A list of parameters, which is passed to ggrepel::geom_label_repel().

keep_scales

If TRUE, keep the original data with ggplot2::geom_blank() so that the highlighted plot has the same scale with the data.

calculate_per_facet

(Experimental) If TRUE, include the facet variables to calculate the grouping; in other words, highlighting is done on each facet individually.

line_label_type

(Experimental) Method to add labels (or texts) on the highlighted lines.

"ggrepel_label"

Use ggrepel::geom_label_repel().

"ggrepel_text"

Use ggrepel::geom_text_repel().

"text_path"

Use geomtextpath::geom_textline() for lines and geomtextpath::geom_textpath() for paths.

"label_path"

Use geomtextpath::geom_labelline() for lines and geomtextpath::geom_labelpath() for paths.

"sec_axis"

Use secondary axis. Please refer to Simon Jackson's blog post for the trick.

unhighlighted_colour

(Deprecated) Colour for unhighlighted geoms.

Examples

d <- data.frame(
  idx = c(1, 1, 1, 2, 2, 2, 3, 3, 3),
  value = c(1, 2, 3, 10, 11, 12, 9, 10, 11),
  category = rep(c("a", "b", "c"), 3),
  stringsAsFactors = FALSE
)

# Highlight the lines whose max values are larger than 10
ggplot(d, aes(idx, value, colour = category)) +
  geom_line() + gghighlight(max(value) > 10)

# Highlight the points whose values are larger than 10
ggplot(d, aes(idx, value)) +
  geom_point() +
  gghighlight(value > 10, label_key = category)

# Specify the styles for unhighlighted layer
ggplot(d, aes(idx, value, colour = category)) +
  geom_line(linewidth = 5) +
  gghighlight(max(value) > 10,
    unhighlighted_params = list(linewidth = 1)
  )

Objects exported from other packages

Description

These objects are imported from other packages. Follow the links below to see their documentation.

dplyr

n

ggplot2

aes

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.