Hi the hover text does not work in this script. Any idea ??
It should display the text withing the text variable below.
mm ← structure(list(Taxa = structure(1:13, .Label = c(“Streptococcus salivarius”,
“Lactobacillus gasseri”, “Escherichia coli”, “Shigella boydii”,
“Pseudomonas aeruginosa”, “Staphylococcus aureus”, “Enterococcus faecalis”,
“Staphylococcus epidermidis”, “Bacteroides vulgatus”, “Bacillus sp.”,
“Clostridium perfringens”, “Propionibacterium acnes”, “Bifidobacterium longum”
), class = “factor”), variable = structure(c(1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(“Relative_abundance_median”,
“Relative_abundance_mean”), class = “factor”), value = c(6.77,
6.28, 13.76, 13.78, 7.25, 6.35, 6.82, 6.13, 6.36, 6.77, 5.34,
7.17, 7.2)), .Names = c(“Taxa”, “variable”, “value”), row.names = c(NA,
13L), class = “data.frame”)
col_vector1=c(“#76021F”, “#3BF13B”, “#69E4ED”, “#956FF5”, “#FCDA61”, “#075B0E”,
“#F7ABC4”, “#324961”, “#F83821”, “#DE1A88”, “#6BFDB2”, “#1887DB”,
“#B36317”)
leg ← list(
bgcolor = “#EEE0E5”,
bordercolor = “#FFF0F5”,
borderwidth = 2
)
ang ← list(tickangle = 45)
mar ← list(
l = 50,
r = 50,
b = 120,
t = 50,
pad = 4,
autoexpand=T
)
Taxa variable value
1 Streptococcus salivarius Relative_abundance_median 6.77
2 Lactobacillus gasseri Relative_abundance_median 6.28
3 Escherichia coli Relative_abundance_median 13.76
4 Shigella boydii Relative_abundance_median 13.78
5 Pseudomonas aeruginosa Relative_abundance_median 7.25
6 Staphylococcus aureus Relative_abundance_median 6.35
7 Enterococcus faecalis Relative_abundance_median 6.82
8 Staphylococcus epidermidis Relative_abundance_median 6.13
9 Bacteroides vulgatus Relative_abundance_median 6.36
10 Bacillus sp. Relative_abundance_median 6.77
11 Clostridium perfringens Relative_abundance_median 5.34
12 Propionibacterium acnes Relative_abundance_median 7.17
13 Bifidobacterium longum Relative_abundance_median 7.20
text = paste(‘Percent abundance:’,mm$value,“
”, paste(“Species”,“:”,as.character(mm$variable),sep=“”),sep=“”)
pl ← plot_ly(mm,
x = ~Taxa,
y = ~value,
color = ~Taxa,
mode=“markers”,
type = ‘bar’ ,
marker = list(color = col_vector1
text = text,
hoverinfo=text ) %>%
layout(margin=mar,
# xaxis=ang,
# bargap=0.7,
# legend=leg,
title=“Realtive Abundance”,
xaxis = list(title =“Percent abundance”),
yaxis = list(title = “Percent abundance”)
)