Restyle highlighted points in a plotly figure
Source:R/plotly_annotation_utils.R
apply_highlight_styling.RdApplies highlight marker styling (fill, size, border) to the points of a
plotly figure whose annotate.by value appears in highlight_vals. Points
are matched on their annotation value parsed out of the hover text rather
than on coordinates, because ggplotly() encodes categorical axes as numeric
positions that will not match the raw data values.
Usage
apply_highlight_styling(
fig,
annotate.by,
highlight_vals,
style,
default.size = NULL,
show.others = TRUE,
require.markers = FALSE
)Arguments
- fig
Plotly figure object.
- annotate.by
Character. Name of the hover field holding the values to match.
- highlight_vals
Character vector. Values identifying the points to highlight.
- style
A named list of styling values with elements
color,size,border.colorandborder.width. Empty/NAelements are left unchanged.- default.size
Numeric, or
NULL. Marker size to fall back on for traces that carry no explicit size.- show.others
Logical. Whether "show.others" was enabled in the plot.
- require.markers
Logical. When
TRUE, only traces drawing point markers are restyled (use it when other scatter traces, such as box outlines, come from the same data).