Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

colorbar

Modify the colorbar


Description

Modify the colorbar

Usage

colorbar(p, ..., limits = NULL, which = 1)

Arguments

p

a plotly object

...

arguments are documented here https://plotly.com/r/reference/#scatter-marker-colorbar.

limits

numeric vector of length 2. Set the extent of the colorbar scale.

which

colorbar to modify? Should only be relevant for subplots with multiple colorbars.

Author(s)

Carson Sievert

Examples

p <- plot_ly(mtcars, x = ~wt, y = ~mpg, color = ~cyl)

# pass any colorbar attribute -- 
# https://plotly.com/r/reference/#scatter-marker-colorbar
colorbar(p, len = 0.5)

# Expand the limits of the colorbar
colorbar(p, limits = c(0, 20))
# values outside the colorbar limits are considered "missing"
colorbar(p, limits = c(5, 6))

# also works on colorbars generated via a z value
corr <- cor(diamonds[vapply(diamonds, is.numeric, logical(1))])
plot_ly(x = rownames(corr), y = colnames(corr), z = corr) %>%
 add_heatmap() %>%
 colorbar(limits = c(-1, 1))

plotly

Create Interactive Web Graphics via 'plotly.js'

v4.10.0
MIT + file LICENSE
Authors
Carson Sievert [aut, cre] (<https://orcid.org/0000-0002-4958-2844>), Chris Parmer [aut], Toby Hocking [aut], Scott Chamberlain [aut], Karthik Ram [aut], Marianne Corvellec [aut] (<https://orcid.org/0000-0002-1994-3581>), Pedro Despouy [aut], Salim Brüggemann [ctb] (<https://orcid.org/0000-0002-5329-5987>), Plotly Technologies Inc. [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.