I'm using R's plotly package inside a Shiny Dashboard to create the funnel chart below.
Current plot.
There is a problem with this chart in that the x-axis displays negative values to the left of 0. Normally this wouldn't be a problem of course, but this is a funnel chart, so the values to the left of 0 aren't really negative, because they represent count data. I don't know how to fix it.
Desired plot.
The code is
output$plot_piramide_casos <- renderPlotly({
m <- list(
l = 50,
r = 50,
b = 100,
t = 100,
pad = 4
)
plot_ly(piramide_casos(), x = ~Freq_n, y = ~Faixa, type = 'bar', color = ~Sexo, colors = c("darkorange1", "dodgerblue3"),
text = ~paste("Faixa Etária: ", Faixa, '<br>Número Absoluto:', Freq, '<br>Proporção:', prop,"%"), hoverinfo = 'text') %>%
layout(barmode='relative',
xaxis = list(title = "População", tickformat = "digits", zeroline = FALSE),
yaxis = list(title = "Faixa Etária", zeroline = FALSE)) %>%
layout(title = "Casos confirmados de COVID-19", titlefont = list(size = 24, face="bold"))%>%
layout(autosize = F, width = 545, height = 400, margin = m)
})



type="funnel", as in example here - YBS