0

enter image description here

I am struggling to disable the default hovertext. I have added custom hovertext but the default is still showing besides the custom text. I have tried hoverinfo = 'none' and hoverinfo = ''. In the screenshot above the arrow points to the default hover text. Is there a way to disable that text?

Here is my code:

temp <- structure(list(therapy_class = structure(c(1L, 1L, 1L, 1L, 1L, 
1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 
4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 
7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 8L, 8L), .Label = c("ALK Inhibitors", 
"Anti-VEGF-based therapies", "EGFR TKIs", "Non-Platinum-based", 
"PD-1/PD-L1-based therapies", "Platinum-based", "Single agent chemotherapies", 
"Other"), class = c("ordered", "factor")), Year_month = c("Jul 2020", 
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020", "Jul 2020", 
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020", "Jul 2020", 
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020", "Jul 2020", 
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020", "Jul 2020", 
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020", "Jul 2020", 
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020", "Jul 2020", 
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020", "Jul 2020", 
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020"), 
    value = c(0.028735632183908, 0.0327510917030568, 0.0239130434782609, 
    0.0245901639344262, 0.0237580993520518, 0.027972027972028, 
    0.0804597701149425, 0.0698689956331878, 0.0478260869565217, 
    0.0491803278688525, 0.0626349892008639, 0.0559440559440559, 
    0.0977011494252874, 0.111353711790393, 0.1, 0.108606557377049, 
    0.08207343412527, 0.0839160839160839, 0.00766283524904215, 
    0.0109170305676856, 0.00434782608695652, 0.00614754098360656, 
    0.00647948164146868, 0.0116550116550117, 0.478927203065134, 
    0.475982532751092, 0.456521739130435, 0.456967213114754, 
    0.511879049676026, 0.484848484848485, 0.162835249042146, 
    0.170305676855895, 0.239130434782609, 0.227459016393443, 
    0.183585313174946, 0.179487179487179, 0.0804597701149425, 
    0.0698689956331878, 0.0630434782608696, 0.0676229508196721, 
    0.08207343412527, 0.0955710955710956, 0.0632183908045977, 
    0.0589519650655022, 0.0652173913043478, 0.0594262295081967, 
    0.0475161987041037, 0.0606060606060606), count = c(15L, 15L, 
    11L, 12L, 11L, 12L, 42L, 32L, 22L, 24L, 29L, 24L, 51L, 51L, 
    46L, 53L, 38L, 36L, 4L, 5L, 2L, 3L, 3L, 5L, 250L, 218L, 210L, 
    223L, 237L, 208L, 85L, 78L, 110L, 111L, 85L, 77L, 42L, 32L, 
    29L, 33L, 38L, 41L, 33L, 27L, 30L, 29L, 22L, 26L)), row.names = c(NA, 
-48L), class = c("tbl_df", "tbl", "data.frame"))

    plot_ly(
    data = temp,
    y = ~value,
    x = ~Year_month,
    color = ~therapy_class
) %>%
    add_lines(
              hovertemplate = paste(temp$therapy_class,
                                    "<br>Count:", temp$count,
                                    "<br>PCT:", sprintf("%1.2f%%", 100*temp$value))) %>%
    layout(
        yaxis = list(
            tickformat = "%",
            title = ""
        ),
        xaxis = list(title = ""),
        legend = list(
            orientation = "h", yanchor = "bottom", y = -0.5,
            font = list(size = 10)
        )
    )
1
  • @YBS The info I want to show is inside the green box, the 3 lines. Outside the box it again shows the therapy class. The screenshot has the arrow pointed to the line I don't want to show. Commented Jul 28, 2021 at 19:30

1 Answer 1

0
plot_ly(
    data = temp,
    y = ~value,
    x = ~Year_month,
    color = ~therapy_class,
    name = ""
)

Needed to pass name parameter as "". It was using the default and using that in hover info.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.