сюжетно в R: добавление меток к диаграммам площади поверхности через макет?

Я работаю с диаграммами площади поверхности в plotly, и мне интересно, как изменить метки, поскольку процесс кажется отличным от плоских диаграмм, поэтому у меня возникли проблемы с пониманием того, как они должны быть расположены. Я получаю предупреждающее сообщение, но вижу, что метка заголовка пропала, и мне интересно, как изменить ось X и ось Y. Ниже приведен мой воспроизводимый код с использованием встроенного набора данных freeny:

#stack question for surface plot
library(plotly)
library(zoo)

#set data
master = freeny
master$year = round(as.numeric(row.names(master)))
master$month = sample(1:6, 39, replace=TRUE)
master$month = paste0("0",master$month)
master$date = as.Date(with(master, paste0(year,"-" ,month,"-" ,"28")))
master$weekday = weekdays(master$date)
master$month_year = as.yearmon(master$date)
master


#build matrix
matrix_d = xtabs(income.level ~ month_year + weekday, master)
matrix_d

#plot
p = plot_ly(z = ~matrix_d) %>% add_surface()
p


#label
 p = layout(p,              # all of layout's properties: /r/reference/#layout
                title = "income levels across month and weekdays", # layout's title: /r/reference/#layout-title
                xaxis = list(           # layout's xaxis is a named list. List of valid keys: /r/reference/#layout-xaxis
                  title = "weekday",     # xaxis's title: /r/reference/#layout-xaxis-title
                  showgrid = F        # xaxis's showgrid: /r/reference/#layout-xaxis-showgrid
                ),
                yaxis = list(           # layout's yaxis is a named list. List of valid keys: /r/reference/#layout-yaxis
                  title = "month_year"      # yaxis's title: /r/reference/#layout-yaxis-title
                ),
            zaxis = list(
              title = "income_level"
            ))
p


Warning message:
'layout' objects don't have these attributes: 'zaxis'
Valid attributes include:
'font', 'title', 'titlefont', 'autosize', 'width', 'height', 'margin', 'paper_bgcolor', 'plot_bgcolor', 'separators', 'hidesources', 'smith', 'showlegend', 'dragmode', 'hovermode', 'xaxis', 'yaxis', 'scene', 'geo', 'legend', 'annotations', 'shapes', 'images', 'updatemenus', 'ternary', 'mapbox', 'radialaxis', 'angularaxis', 'direction', 'orientation', 'barmode', 'bargap', 'mapType'

ИЗМЕНИТЬ ПОСЛЕДУЮЩИЕ:

Разместил ответ ниже на главный вопрос, но в качестве продолжения, как мне добавить значения к отметкам? Я предполагаю, что есть способ передать вектор списка порядковых значений в тики, такие как c ("0" = "воскресенье", "1" = "понедельник" ...). Это точно?

Цените помощь !!!


person LoF10    schedule 30.11.2016    source источник


Ответы (1)


Нашел ответ в другом сообщении на случай, если он кому-нибудь понадобится. Мне интересно, как добавить конкретный месяц и день недели к отметкам?

p <- plot_ly(z = ~matrix_d) %>% add_surface() %>%
layout(title = 'income levels across month and weekdays',
       scene = list(xaxis = list(title = 'weekday'),
                    yaxis = list(title = 'month'),
                    zaxis = list(title = 'income_level')))

p
person LoF10    schedule 30.11.2016