2016-11-30 1 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' 

EDITのフォロー:

答えトップの質問に下回るが、私は目盛りに値を追加する方法をフォローとして投稿されました?私は、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 
関連する問題