* `?plot_ly` documents R-specific arguments (e.g., `color`, `stroke`, etc). # `plotly_json()` should match up with plotly.js' `schema()` # If no plot is provided, it shows JSON of the previously printed plot # `plotly_json()`: focus on `data` and `layout` * The online figure reference doesn't always reflect the version of plotly.js used in the R package, but `schema()` does! * `plotly_json()` should align with the figure reference * Especially useful for debugging things that _map to_ plotly.js (e.g., `color`, `stroke`, `ggplotly()`). * Use `plotly_json()` to inspect the underlying JSON Why isn't the `stroke` on this plot black? Can you make the `span` be a function of `count`?ģ. Use `color`/`colors` for fill-color and `stroke`/`strokes` for outline-colorġ. Specify the range via `colors` (here a () palette name, see `RColorBrewer::` for options) Mapping data to `color` will impose it's own color scheme * x = ~factor(animal, c("monkeys", "giraffes", "orangutans")), More common trace types have a dedicated "layer" function (e.g., `add_bars()`).ĭiscrete axis ordering: use factor levels (character strings appear alphabetically) # `plotly_json()` to view underlying JSON The `split` argument is a more explicit way to split data into multiple traces `name`), `plot_ly()` generates one trace per level. X = c('giraffes', 'orangutans', 'monkeys'),įor attributes that require a scalar value (e.g. In R, use `plot_ly()` (or `ggplotly()`) to create a **plotly** object, then `add_trace()` to add any trace you want. A *trace* is a mapping from data to visual. What actually happens when a plotly object is printed and rendered locally?Ī Plotly *figure* is made up of trace(s) and a layout. * `plot_ly()` is designed to give more "R-like" defaults * Every **plotly** chart is powered by (), *plus some extra R/JS magic* □ □. I'll try to check these questions periodically (upvote questions if you'd like them answered!) (3) Ask me any question at any time by going to () and enter event code #8464 (or use ()). * Click "Save a Permanent Copy" to copy the project to your account. * Login or sign up to RStudio Cloud (it's free) This hosted RStudio instance contains materials for today's workshop. # Carson Sievert Software Engineer, RStudio # Interactive dataviz on the web with R, plotly, and shiny Interactive dataviz on the web with R, plotly, and shinyĬlass: center, middle, inverse, title-slide
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |