我有以下DF: mydf
我想使用“ plot_ly”构建图形,其中:
X轴-> Corrida
Y轴-> TubosComDefeitoPorCorrida
在条形图上,当用户通过鼠标时,必须显示以下消息:
text = '</br> \n Total de tubos Inspecionados: ', TubosTotalPorCorrida #for each number of "Corrida",
'</br> \n Total de tubos ippns: ', TubosComDefeitoPorCorrida #for each number of "Corrida",
就像下面的图片: graph
顺便说一下,我的图形代码实际上是:
d <- plot_ly(data = tabela, x = ~tabela[,categoria], y = ~tabela[,eixoY],
##marker = list(color = "Red"),
type = "bar",
showlegend = F,
hoverinfo = 'text',
text = ~paste(switch (categoria,"corrida" = "Corrida","veio" = "Veio","sequencial" = "Barra sequencial","bloco" = "Bloco"), tabela[,categoria],
'</br> \n Total de tubos Inspecionados: ', lupas_inspecionadas,
'</br> \n Total de tubos ippns: ', tubos_indicados,
'</br> \n Qtd. Tubos ippns: ', tabela$ippn,
'</br> \n Percentual Absoluto: ', tabela$perc_absoluto,
'</br> \n Percentual Relativo: ', tabela$perc_relativo)) %>%
layout(legend = list(orientation = 'h')) %>%