【问题标题】:Hide the y-axis line from the bar chart using plotly() in r使用 r 中的 plotly() 从条形图中隐藏 y 轴线
【发布时间】:2019-06-26 07:05:25
【问题描述】:

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

使用的数据框如下:

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) 

有什么解决办法吗?

【问题讨论】:

    标签: r r-plotly


    【解决方案1】:

    我觉得电脑即使转了也还是把它理解为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)
    

    【讨论】:

      猜你喜欢
      • 2020-11-02
      • 2020-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多