Figure Labels for 2D Charts
library(plotly) f <- list( family = "Courier New, monospace", size = 18, color = "#7f7f7f" ) x <- list( title = "x Axis", titlefont = f ) y <- list( title = "y Axis", titlefont = f ) fig <- plot_ly(x = ~rnorm(10), y = ~rnorm(10), mode = "markers") fig <- fig %>% layout(xaxis = x, yaxis = y) fig
Figure Labels for 3D Charts
library(plotly) set.seed(123) n <- 100 theta <- runif(n, 0, 2*pi) u <- runif(n, -1, 1) fig <- plot_ly(x = ~sqrt(1 - u^2) * cos(theta), y = ~sqrt(1 - u^2) * sin(theta), z = ~u) fig <- fig %>% layout( title = "Layout options in a 3d scatter plot", scene = list( xaxis = list(title = "Cos"), yaxis = list(title = "Sin"), zaxis = list(title = "Z") )) fig
What About Dash?
Learn about how to install Dash for R at https://dashr.plot.ly/installation.
Everywhere in this page that you see
fig, you can display the same figure in a Dash for R application by passing it to the
figure argument of the
Graph component from the built-in
dashCoreComponents package like this:
library(plotly) fig <- plot_ly() # fig <- fig %>% add_trace( ... ) # fig <- fig %>% layout( ... ) library(dash) library(dashCoreComponents) library(dashHtmlComponents) app <- Dash$new() app$layout( htmlDiv( list( dccGraph(figure=fig) ) ) ) app$run_server(debug=TRUE, dev_tools_hot_reload=FALSE)