Is there a way to hide Trace Names in Plotly (specifically R)?

后端 未结 1 1110
时光说笑
时光说笑 2021-01-21 02:18

I\'ve been wracking my brain over how to get rid of the trace name with plotly and can\'t seem to find anything. It seems adding the trace name is a unique feature of plotly box

相关标签:
1条回答
  • 2021-01-21 02:52

    If you want to hide the trace names in a box chart, you could hide the axis' labels by using showticklabels = F.

    In the example below the trace name is also hidden in the hover labels by setting hoverinfo = 'x'.

    library(plotly)
    housing = read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data")
    colnames(housing) = c("CRIM","ZN","INDUS","CHAS","NOX","RM","AGE","DIS","RAD","TAX","PTRATIO","B","LSTAT","MEDV")
    
    housing %>%
      plot_ly( x = ~RM,
               y = 'RM',
               type="box", 
               name = "RM",
               showlegend = FALSE,
               hoverinfo = 'x'
      ) %>% 
      add_markers(x=6, y="RM",
                  marker = list(color = "blue", size = 15)
      ) %>% layout(yaxis = list(showticklabels = F))
    housing
    

    0 讨论(0)
提交回复
热议问题