[英]Plotly subplot title position r
我使用以下代码创建了带有两个馅饼的 plot。 这必须在 shiny 应用程序中使用 go,因此对于我拥有的代码,在这种情况下我不能使用命令“subplot”。
fig <- fig %>% add_pie(data = data, labels = ~Origin, values = data[[input$display_country]],
name = "Cut", domain = list(row = 0, column = 0),
textposition = 'inside',
textinfo = 'label+percent',
insidetextfont = list(color = '#FFFFFF'),
hoverinfo = 'text',
text = ~paste(round(All*100, digits = 2), '%'),
marker = list(colors = colors,
line = list(color = '#FFFFFF', width = 1)),
title = list(text='<b> Men </b>', y = 0.99, x = 0.5,
xanchor = 'center', yanchor = 'top', size = 15))
fig <- fig %>% add_pie(data = data, labels = ~Origin, values = data[[input$display_country]],
name = "Color", domain = list(row = 0, column = 1),
textposition = 'inside',
textinfo = 'label+percent',
insidetextfont = list(color = '#FFFFFF'),
hoverinfo = 'text',
text = ~paste(round(All*100, digits = 2), '%'),
marker = list(colors = colors,
line = list(color = '#FFFFFF', width = 1)),
title = list(text='<b> Women </b>', y = 0.99, x = 0.5,
xanchor = 'center', yanchor = 'top', size = 15))
fig <- fig %>% layout(grid=list(rows=1, columns=2),
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
fig <- fig %>% config(map, displaylogo = FALSE)
我想让“男人”和“女人”的标题更大,并把它们放在离饼图更远的地方。 我尝试在布局中插入标题选项,但没有任何变化。 有可能吗?
这是数据:
dput(origin_all)
structure(list(Group = c("All immigrants", "All immigrants",
"All immigrants", "All immigrants", "All immigrants", "All immigrants",
"All immigrants", "All immigrants", "All immigrants", "All immigrants"
), Origin = c("EU", "Europe non-EU", "Africa", "Americas", "Asia",
"EU", "Europe non-EU", "Africa", "Americas", "Asia"), Austria = c(0.478348881006241,
0.384286612272263, 0.0148246623575687, 0.0235789380967617, 0.0989609286189079,
0.478348881006241, 0.0235789380967617, 0.0989609286189079, 0.384286612272263,
0.0148246623575687), Belgium = c(0.478005975484848, 0.144150376319885,
0.158031389117241, 0.0511157736182213, 0.168696463108063, 0.478005975484848,
0.0511157736182213, 0.168696463108063, 0.144150376319885, 0.158031389117241
), Bulgaria = c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0), Croatia = c(1,
0, 0, 0, 0, 1, 0, 0, 0, 0), Cyprus = c(0.424042582511902, 0.295767605304718,
0.0237375255674124, 0.0283860396593809, 0.228066250681877, 0.424042582511902,
0.0283860396593809, 0.228066250681877, 0.295767605304718, 0.0237375255674124
), `Czech Republic` = c(0.578244507312775, 0.324023216962814,
0.00574869429692626, 0.0367192775011063, 0.0552643053233624,
0.578244507312775, 0.0367192775011063, 0.0552643053233624, 0.324023216962814,
0.00574869429692626), Denmark = c(0.335901528596878, 0.274491608142853,
0.0146643230691552, 0.0735590606927872, 0.301383465528488, 0.335901528596878,
0.0735590606927872, 0.301383465528488, 0.274491608142853, 0.0146643230691552
), Estonia = c(0.0897587165236473, 0.851310789585114, 0.00768309505656362,
0.00628914358094335, 0.0449582785367966, 0.0897587165236473,
0.00628914358094335, 0.0449582785367966, 0.851310789585114, 0.00768309505656362
), Finland = c(0.423047333955765, 0, 0.182186901569366, 0.0271128006279469,
0.367652982473373, 0.423047333955765, 0.0271128006279469, 0.367652982473373,
0, 0.182186901569366), France = c(0.267972409725189, 0, 0.447541803121567,
0.0571092888712883, 0.227376475930214, 0.267972409725189, 0.0571092888712883,
0.227376475930214, 0, 0.447541803121567), Germany = c(0.440932661294937,
0.300490856170654, 0.0157827083021402, 0.030566243454814, 0.212227493524551,
0.440932661294937, 0.030566243454814, 0.212227493524551, 0.300490856170654,
0.0157827083021402), Greece = c(0.183683022856712, 0.633622765541077,
0.0136560946702957, 0.0322394296526909, 0.136798650026321, 0.183683022856712,
0.0322394296526909, 0.136798650026321, 0.633622765541077, 0.0136560946702957
), Hungary = c(0.650038778781891, 0.258528083562851, 0.0110598411411047,
0.0222733095288277, 0.0581000261008739, 0.650038778781891, 0.0222733095288277,
0.0581000261008739, 0.258528083562851, 0.0110598411411047), Iceland = c(0.641336858272552,
0.154523000121117, 0.0119159128516912, 0.107964612543583, 0.0842596441507339,
0.641336858272552, 0.107964612543583, 0.0842596441507339, 0.154523000121117,
0.0119159128516912), Ireland = c(0.424034059047699, 0.353149563074112,
0.00856592878699303, 0.0984473004937172, 0.115803137421608, 0.424034059047699,
0.0984473004937172, 0.115803137421608, 0.353149563074112, 0.00856592878699303
), Italy = c(0.331417590379715, 0.295012056827545, 0.127562612295151,
0.129452005028725, 0.116555772721767, 0.331417590379715, 0.129452005028725,
0.116555772721767, 0.295012056827545, 0.127562612295151), Latvia = c(0.627548158168793,
0, 0.00299526727758348, 0.0673437118530273, 0.302112907171249,
0.627548158168793, 0.0673437118530273, 0.302112907171249, 0,
0.00299526727758348), Lithuania = c(0.105990558862686, 0.828586518764496,
0.000476859044283628, 0.00629339786246419, 0.0586526542901993,
0.105990558862686, 0.00629339786246419, 0.0586526542901993, 0.828586518764496,
0.000476859044283628), Luxembourg = c(0.776874005794525, 0.0845479294657707,
0.0172871313989162, 0.04091876745224, 0.0803721472620964, 0.776874005794525,
0.04091876745224, 0.0803721472620964, 0.0845479294657707, 0.0172871313989162
), Malta = c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0), Netherlands = c(0.270869314670563,
0.172013342380524, 0.103874139487743
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.