Plotly Charts Examples

library(plotly)

airquality_sept <- airquality[which(airquality$Month == 9),] airquality_sept$Date <- as.Date(paste(airquality_sept$Month, airquality_sept$Day, 1973, sep = "."), format = "%m.%d.%Y") View(airquality_sept) plot_ly(airquality_sept) %>%
add_trace(x = ~Date, y = ~Wind, type = ‘bar’, name = ‘Wind’,
marker = list(color = ‘#C9EFF9’),
hoverinfo = “text”,
text = ~paste(Wind, ‘ mph’)) %>%
add_trace(x = ~Date, y = ~Temp, type = ‘scatter’, mode = ‘lines’, name = ‘Temperature’, yaxis = ‘y2’,
line = list(color = ‘#45171D’),
hoverinfo = “text”,
text = ~paste(Temp, ‘°F’)) %>%
layout(title = ‘New York Wind and Temperature Measurements for September 1973’,
xaxis = list(title = “”),
yaxis = list(side = ‘left’, title = ‘Wind in mph’, showgrid = FALSE, zeroline = FALSE),
yaxis2 = list(side = ‘right’, overlaying = “y”, title = ‘Temperature in degrees F’, showgrid = FALSE, zeroline = FALSE))

plot_ly(airquality_sept) %>%
add_trace(x = ~Date, y = ~Wind, type = ‘bar’, name = ‘Wind’,
marker = list(color = ‘#C9EFF9’),
hoverinfo = “text”,
text = ~paste(Wind, ‘ mph’)) %>%
layout(title = ‘New York Wind and Temperature Measurements for September 1973’,
xaxis = list(title = “”),
yaxis = list(side = ‘left’, title = ‘Wind in mph’, showgrid = TRUE, zeroline = FALSE),
yaxis2 = list(side = ‘right’, overlaying = “y”, title = ‘Temperature in degrees F’, showgrid = FALSE, zeroline = FALSE))

# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link = api_create(p, filename=”multiple-bar_line”)

Leave a Reply

Your email address will not be published. Required fields are marked *