使用 r 中的 plotly() 隐藏条形图中的 y 轴线

Hide the y-axis line from the bar chart using plotly() in r

我正在使用 plot_ly() 可视化水平条形图。不显示 x 轴的轴线,但显示 y 轴的轴线。我不知道如何隐藏条形图的轴线。

使用的dataframe如下:

df <- data.frame("Grade" = c(9,10,11,12), "totalHours" = c(93,81,7,96),
                 "Count" = c(30,16,1,14), "average" = c(3.100,5.062,7.000,6.857))

用于可视化的plot_ly()调用如下:

plot_ly(df, x=df$average, y=df$Grade, 
        type="bar", color=~Grade, orientation = 'h') %>%
  add_text(text=round(df$average), hoverinfo='none', textposition = 'auto', showlegend = FALSE,
           textfont=list(size=12, color="black")) %>%
  layout(yaxis = list(showgrid = FALSE),showlegend=FALSE) 

有解决办法吗?

我觉得电脑就算转了也还是理解为xaxis。我希望这对你有用:

Noax <- list(
  title = "",
  zeroline = FALSE,
  showline = FALSE,
  showticklabels = FALSE,
  showgrid = FALSE
)

plot_ly(df, x=df$average, y=df$Grade, 
        type="bar", color=~Grade, orientation = 'h') %>%
  add_text(text=round(df$average), hoverinfo='none', textposition = 'auto', showlegend = FALSE,
           textfont=list(size=12, color="black")) %>%
  layout(xaxis = Noax)