Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to adjust title space and plot plotly in r

gpX83= plot_ly(df_X83, 
           labels = ~Var1, 
           values=~Freq, 
           type ='pie', sort = F) %>% layout(title = list(text = paste0('Gráfico 83.1','<br>', '<sup>',
                                'Com que frequência você participou de novas capacitações?','</sup>'),x = 0.1), 
     colorway = c('#E41A1C', '#377EB8' , '#4DAF4A', '#984EA3','#FF7F00', '#FFFF33', '#A65628', '#F781BF'),
     legend= list(orientation='h')) 

enter image description here

I need to give a space between the title and area of the graph, does anyone know what function to use?

like image 603
Becca Carneiro Avatar asked Sep 01 '25 02:09

Becca Carneiro


1 Answers

The margin needs a workaround. It can be added to the layout as margin =.

For example:

mrg <- list(l = 50, r = 50,
          b = 50, t = 50,
          pad = 20)

gpX83 <- plot_ly(df, labels = ~Project, values=~Emissions,
                 type ='pie', sort = F) %>%
  layout(title = list(text = paste0('Gráfico 83.1','<br>', '<sup>',
                                    'Com que frequência você participou de novas capacitações?','</sup>'),x = 0.1),
         colorway = c('#E41A1C', '#377EB8' , '#4DAF4A', '#984EA3','#FF7F00', '#FFFF33', '#A65628', '#F781BF'),
         legend= list(orientation='h'), 
         margin = mrg) 
like image 150
Mohanasundaram Avatar answered Sep 03 '25 02:09

Mohanasundaram