2016-11-30 4 views
0

평평하게 표면 영역 차트 작업을하고 있으며 평면 차트와 다른 모양으로 라벨을 변경하는 방법이 궁금해서 레이아웃 배치 방법을 고민하는 데 어려움을 겪고 있습니다. 경고 메시지가 나타나지만 제목 레이블이 사라져서 X 축과 Y 축을 변경하는 방법을 궁금해합니다. 다음은 그 데이터 세트 freeny 내장하여 내 재현 코드는 다음과 같습니다R에 음모 : 레이아웃을 통해 표면 영역 차트에 라벨을 추가 하시겠습니까?

#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"= "sunday", "1"= "Monday"...)와 같은 틱에 서수 값 목록 벡터를 공급하는 방법이 있다고 가정합니다. 정확합니까?

감사합니다.

답변

0

누군가가 필요로하는 경우를 대비하여 다른 게시판에서 답변을 찾았습니다. 나는 눈금에 특정 달과 평일을 추가하는 방법이 궁금합니다.

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