I have created plot with two pies with the following code. This has to go inside a shiny app, so for the code that I have I cannot use the command "subplot" in this case.
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)
I would like to make the titles "Men" and "Women" bigger, and put them farther from the pie charts. I tried inserting the options for the title in the layout, but nothing changes. Is it possible to do?
Here is the data:
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
There isn't a control built-in, but you can make it do what you want in a roundabout manner. You can add a new line with <br>
, as if your title is two lines, and just use white space in the second line.
Additionally, when you set the title, you can set the font size. However, the way you've documented size
won't work.
For example:
title = list(text='<b> Men <br> </b>', font = list(size = 15))
This reflects your plots (essentially) where the left has the title set with the code I've provided and the right has the code you've provided.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.