Examples for 'plotly::style'


Modify trace(s)

Aliases: style

Keywords:

### ** Examples


# style() is especially useful in conjunction with ggplotly()
# It allows you to leverage the underlying plotly.js library to change 
# the return result of ggplotly()
(p <- ggplotly(qplot(data = mtcars, wt, mpg, geom = c("point", "smooth"))))
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
Error in loadNamespace(name): there is no package called 'webshot'
# removes hoverinfo for the line/ribbon traces (use `plotly_json()` to verify!)
style(p, hoverinfo = "none", traces = c(2, 3))
Error in loadNamespace(name): there is no package called 'webshot'
# another example with plot_ly() instead of ggplotly()
marker <- list(
  color = "red",
  line = list(
    width = 20,
    color = "black"
 )
)
(p <- plot_ly(x = 1:10, y = 1:10, marker = marker))
No trace type specified:
  Based on info supplied, a 'scatter' trace seems appropriate.
  Read more about this trace type -> https://plotly.com/r/reference/#scatter
No scatter mode specifed:
  Setting the mode to markers
  Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
Error in loadNamespace(name): there is no package called 'webshot'
# note how the entire (marker) object is replaced if a list is provided
style(p, marker = list(line = list(color = "blue")))
No trace type specified:
  Based on info supplied, a 'scatter' trace seems appropriate.
  Read more about this trace type -> https://plotly.com/r/reference/#scatter
No scatter mode specifed:
  Setting the mode to markers
  Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
Error in loadNamespace(name): there is no package called 'webshot'
# similar to plotly.js, you can update a particular attribute like so 
# https://github.com/plotly/plotly.js/issues/1866#issuecomment-314115744
style(p, marker.line.color = "blue")
No trace type specified:
  Based on info supplied, a 'scatter' trace seems appropriate.
  Read more about this trace type -> https://plotly.com/r/reference/#scatter
No scatter mode specifed:
  Setting the mode to markers
  Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
Error in loadNamespace(name): there is no package called 'webshot'
# this clobbers the previously supplied marker.line.color
style(p, marker.line = list(width = 2.5), marker.size = 10)
No trace type specified:
  Based on info supplied, a 'scatter' trace seems appropriate.
  Read more about this trace type -> https://plotly.com/r/reference/#scatter
No scatter mode specifed:
  Setting the mode to markers
  Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
Error in loadNamespace(name): there is no package called 'webshot'

[Package plotly version 4.10.0 Index]