散点图 - 在R中显示 - 显示值

时间:2017-03-28 06:25:17

标签: r plotly

我正在使用Plotly和R来创建散点图。可重现的数据示例如下:

df <- structure(list(Category = structure(1:3, .Label = c("Tea", "Coffee", 
"Noodles", "Ketchup", "Jam", "DetergentPowder", "DetergentCakes", 
"Dishwashbar", "DishwashLiquids", "FloorCleaners", "ToiletSoaps", 
"Shampoo", "Toothpaste", "ToothPowder", "Deos", "SkinCreams", 
"Facewash", "Handwash", "Icecreams"), class = "factor"), Kirana = c(25, 
16, 12), PettyTrader = c(146, 104, 55)), .Names = c("Category", 
"Kirana", "PettyTrader"), row.names = c(NA, -3L), class = c("tbl_df", 
"tbl", "data.frame"))

我的情节代码如下:

plot_ly(df, x = ~Kirana, y = ~PettyTrader, text = ~Category, type = 'scatter', mode = 'markers',
        marker = list(size = ~PettyTrader/5, color = ~Category,opacity = 0.5)) %>%
  layout(title = 'Shop Type by Categories Sold',
         xaxis = list(showgrid = FALSE),
         yaxis = list(showgrid = FALSE))

我当前的图表在将鼠标悬停在气泡上时会显示类别标签,但我希望默认情况下显示标签。我怎么能这样做?

0 个答案:

没有答案