I'm trying to create a simple bar chart using the plotly package in R. I want to add labels above each bar, but I've only be able to successfully add in the counts. Is it all possible to add in percentages next to each count? This is what I have:
fig_valve <- plot_ly(valve_df,
x = ~vlvsz_c,
y = ~count,
type = "bar",
hoverinfo = "x+y")
fig_valve <- fig_valve %>%
add_text(text = ~count,
textposition = "top",
textfont = list(size = 11, color = "black"),
showlegend = FALSE) %>%
layout(title = "",
xaxis = list(title = "Valve Size", showgrid = FALSE),
yaxis = list(title = "Count", showgrid = FALSE),
showlegend = FALSE,
font = t)
I'm wondering if I can add in the percentages for each category. Greatly appreciate any suggestions!

