У меня сюжетный сюжет, у которого нет правого левого поля (ни внизу).Не удается найти документацию для добавления этого дополнительного пространства, поэтому моя ось y (этот график находится в горизонтальном режиме) не обрезается.
ui.R:
tabItem(tabName = "ga",
column(12, offset = 2,
plotlyOutput("plot")
)
)
server.R:
sesiones_por_fuente <- reactive({
sesiones_ga <- read_csv("https://www.dropbox.com/s/w2ggnb0p4mz2nus/sesiones-2018.csv?dl=1", skip = 0)
sesiones_ga <- sesiones_ga %>%
group_by(sources) %>%
summarise(sessions = sum(sessions))
})
m <- list(
l = 200,
r = 50,
b = 100,
t = 100,
pad = 20
)
output$plot <- renderPlotly({
plot_ly(sesiones_por_fuente(), x = ~sessions, y = ~sources, type = 'bar',
width = 1200, height = 600, margin = m, orientation = 'h', pad=4) %>%
layout(title = "Sesiones por mes",
xaxis = list(title = ""),
yaxis = list(title = "")) %>%
layout(hovermode = 'compare',
separators = ',')
})
набор данных:
Вы можете загрузить данные с помощью:
sesiones_por_fuente <- read_csv("https://www.dropbox.com/s/w2ggnb0p4mz2nus/sesiones-2018.csv?dl=1", skip = 0)
или с помощью воссоздать его с помощью функции dput:
sesiones_por_fuente <- structure(list(sources = c("adwords", "ccl", "criteo", "directo",
"email", "facebookads", "onesignal", "organico", "redes sociales",
"referencias", "rpp", "spam"), sessions = c(4534932L, 265532L,
3959787L, 4290376L, 3870548L, 3125880L, 2345860L, 7002943L, 75382L,
15061160L, 222730L, 5971162L)), class = c("tbl_df", "tbl", "data.frame"
), .Names = c("sources", "sessions"), row.names = c(NA, -12L), spec = structure(list(
cols = structure(list(date = structure(list(format = ""), .Names = "format", class = c("collector_date",
"collector")), hour = structure(list(), class = c("collector_character",
"collector")), deviceCategory = structure(list(), class = c("collector_character",
"collector")), source = structure(list(), class = c("collector_character",
"collector")), medium = structure(list(), class = c("collector_character",
"collector")), sessions = structure(list(), class = c("collector_integer",
"collector")), year = structure(list(), class = c("collector_integer",
"collector")), month = structure(list(), class = c("collector_character",
"collector")), sources = structure(list(), class = c("collector_character",
"collector"))), .Names = c("date", "hour", "deviceCategory",
"source", "medium", "sessions", "year", "month", "sources"
)), default = structure(list(), class = c("collector_guess",
"collector"))), .Names = c("cols", "default"), class = "col_spec"))