简体   繁体   中英

Remove double legend plotly in R

I don't know why I have a double legend. How to remove the second legend where it is written "Aa"

Code:

city = c("paris", "lyon", "lyon", "marseille", "lille", "toulouse", "bordeaux")
start = c("2018-08-04", "2018-07-25", "2018-07-30", "2018-07-29", "2018-08-03", "2018-08-04", "2018-08-03")
max = c(36.4, 37.2, 38.4, 37.4, 36.7, 34.9, 34.8)
duration = c(4, 3,  8, 10,  5,  4,  3)

tab = as.data.frame(city, start, duration, max)
tab$duration = as.integer(tab$duration)

在此处输入图片说明

t <- list(
         family = "sans serif",
         size = 14,
         color = toRGB("grey50"))

bubbleplot <- plot_ly(tab, x = ~start, y = ~max,
                      text = ~paste(duration, "jours"), 
                      color = ~city,  mode='markers+text'
                      )
bubbleplot = bubbleplot %>% add_markers(
                            marker = list(size = ~duration*4, opacity = 0.7,
                                          sizemode = "diameter"))
bubbleplot <- bubbleplot %>% add_text(textfont = t, textposition = "inside")

bubbleplot

在此处输入图片说明

Use the following,

 t <- list(
  family = "sans serif",
  size = 14,
  color = toRGB("grey50"))

bubbleplot <- plot_ly(tab, x = ~start, y = ~max,
                      text = ~paste(duration, "jours"), 
                      color = ~city,  mode='markers+text'
) 

bubbleplot = bubbleplot %>% add_markers(
  marker = list(size = ~duration*4, opacity = 0.7,
                sizemode = "diameter"))  %>% add_text(x = ~start, y = ~max,
                                                      text = ~paste(duration, "jours"), textfont = t, textposition = "inside", data = tab, inherit = F)

bubbleplot

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM