密谋R隐藏所有标签,刻度,图例等

时间:2019-04-26 15:21:30

标签: r plotly r-plotly

我正在尝试使用Plotly R图(条形图)删除条形图周围的所有文本,但是您无法看到它的工作状态。

图片now

图片goal

这是我用来创建“现在”图像的代码。

library(plotly)

left=30
right=70

data = data.frame(left,right)

ax <- list(title = "", zeroline = FALSE, showline = FALSE,showticklabels = FALSE,showgrid = FALSE, showlegend = FALSE, showgrid=FALSE)
scene = list(xaxis = ax, yaxis = ax)

plot_ly(type = 'bar', orientation = 'h') %>%
  add_trace(x = left,
            marker = list(color = 'rgba(246, 78, 139, 0.6)',
                          line = list(color = 'rgba(246, 78, 139, 1.0)',width = 1)),
            hoverinfo = 'text', text = paste0("Left=",data$left,"%") , hoverinfo="all",
            hoverlabel = list(bgcolor="#272b30",bordercolorsrc ="#272b30",bordercolor="rgba(0,0,0,0)",font=list(color="white", size=12, family="sans-serif"))) %>%
  add_trace(x = right,
            marker = list(color = 'rgba(58, 71, 80, 0.6)',
                          line = list(color = 'rgba(58, 71, 80, 1.0)',width = 1)),
            hoverinfo = 'text', text = paste0("Right=",data$right,"%") , hoverinfo="all",
            hoverlabel = list(bgcolor="#272b30",bordercolorsrc ="#272b30",bordercolor="rgba(0,0,0,0)",font=list(color="white", size=12, family="sans-serif"))) %>% 
  layout(paper_bgcolor='rgba(0,0,0,0)', plot_bgcolor='rgba(0,0,0,0)',
         scene = scene,showlegend = FALSE,barmode = 'relative', autosize = F, margin = list(l=0,r=0,t=0,b=0,pad=0))

谢谢

0 个答案:

没有答案