2

estoy tratando de hacer un subplot con dos graficos en plotly que tenían caption (en layouts, annotations=list(text)), pero no puedo sacarlos del subplot y me quedan en el medio de los graficos. A alguien se le ocurre como sacarlo?

Sobre los dos gráficos que ya tengo(g14So16 y g3E16) quiero compararlos en un solo grafico. Esto está pensado para una gran demanda de consultas, quizás lo más simple sea volver a escribir el código del gráfico sin la fuente, pero creo que debería poder eliminarse o modificarse el layout

Este es el codigo del plotly:

g14So16<- plot_ly(tabla1.3_GrSo2, x=reorder(tabla1.3_GrSo2$AGLOMERADO,-tabla1.3_GrSo2$Media)  ,y=~tabla1.3_GrSo2$Varones, type = 'bar', name = 'Varones', 
        marker = list(color ="#219C97")) %>% 
  add_trace(y = tabla1.3_GrSo2$Mujeres, name = 'Mujeres', marker = list(color = "#DFB021")) %>% 
  layout(xaxis = list(title = "Aglomerado", tickangle = -70, size=0.7, colour = "#6F6F6E"),
         yaxis=  list(title = "Tasa subocupación",  size=0.7, colour = "#6F6F6E", range= c(0,20)),
         margin = list(b = 190, autosize=TRUE, autoexpand=TRUE),
         barmode = 'group', 
         title = list(x = 0.65, y = -0.65,
                text= "Tasas de subocupación según sexo, por aglomerado",
                size= 15,
                xanchor='right', yanchor='auto', xshift=0, yshift=0),
         annotations = list(x = 0.75, y = -0.75, #position of text adjust as needed 
                text = 'Fuente: INDEC, Dirección de estadísticas sectoriales en base a a <a href=\"https://www.indec.gob.ar/uploads/informesdeprensa/indicadores_eph_3trim16.pdf" > informe EPH 3T 2016 </a>',  
                showarrow = F, xref='paper', yref='paper', 
                xanchor='right', yanchor='auto', xshift=0, yshift=0,
                font=list(size=10, color="#6F6F6E")),
          legend=list(x=100, y=0.5, title = list (text = '<b> Sexo </b>')))

Este es el codigo del subplot:

sp2<- g14So16 %>% layout( yaxis=list( range= c(0,80)), annotations=NULL) %>%
  subplot(style(g3E16,showlegend= TRUE, showannotations=FALSE), 
          nrows= 2,
          shareX=TRUE, shareY= TRUE, titleX = FALSE, titleY=FALSE,
          which_layout = 0)   %>% 
  layout( yaxis=list( range= c(0,80)),
          title= list(x = 0.75, y = -0.75,text= "Tasas de empleo y subocupación por aglomerado, Año 2016", size= 10,
          xshift=0, yshift=0),
          annotations=list(NULL)
         ) 

introducir la descripción de la imagen aquí

1 respuesta 1

0

Estimada Romina, bienvenida a stackoverflow. No me es posible reproducir tu código debido a que no cuento con las bases, pero te sugiero eliminar las líneas de "text" en el código para que no salgan en la gráfica. Quedaría algo así:

g14So16<- plot_ly(tabla1.3_GrSo2, x=reorder(tabla1.3_GrSo2$AGLOMERADO,-tabla1.3_GrSo2$Media)  ,y=~tabla1.3_GrSo2$Varones, type = 'bar', name = 'Varones', 
        marker = list(color ="#219C97")) %>% 
  add_trace(y = tabla1.3_GrSo2$Mujeres, name = 'Mujeres', marker = list(color = "#DFB021")) %>% 
  layout(xaxis = list(title = "Aglomerado", tickangle = -70, size=0.7, colour = "#6F6F6E"),
         yaxis=  list(title = "Tasa subocupación",  size=0.7, colour = "#6F6F6E", range= c(0,20)),
         margin = list(b = 190, autosize=TRUE, autoexpand=TRUE),
         barmode = 'group', 
         title = list(x = 0.65, y = -0.65,
                size= 15,
                xanchor='right', yanchor='auto', xshift=0, yshift=0),
         annotations = list(x = 0.75, y = -0.75, #position of text adjust as needed  
                showarrow = F, xref='paper', yref='paper', 
                xanchor='right', yanchor='auto', xshift=0, yshift=0,
                font=list(size=10, color="#6F6F6E")),
          legend=list(x=100, y=0.5, title = list (text = '<b> Sexo </b>')))

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.