我在剧情中有以下栏,我想:
我的代码是:
library(plotly)
plot_ly(x = c('100-200','200-400', '400-600','600-800','800- 1000'),
y = c(12261,29637,17469,11233,17043),
name = "dd",
type = "bar",
xaxis = list(title ="tr"),
yaxis = list(title = "cc") ,
text = c(12261,29637,17469,11233,17043),textposition = 'auto') %>%
layout(
xaxis = list(tickangle=15, title = " "),
yaxis = list(title = " "))
Run Code Online (Sandbox Code Playgroud)
感谢您的意见 :)
问题 1:使 x 轴标题远离轴标签,这样它们就不会重叠这个问题可以通过使用in
设置适当的边距来解决。
问题2:将Y轴标签变大。在问题 3 中
使用
:将条形值置于条形顶部。与
使用margin = list(b=100, l=100)layoutxaxis = list(titlefont=list(size=30))layout
add_texttextposition = 'top'
library(plotly)
x <- c('100-200','200-400', '400-600','600-800','800-1000')
y <- c(12261,29637,17469,11233,17043)
labs <- c(12261,29637,17469,11233,17043)
plot_ly(x = x, y = y,
name = "dd",
type = "bar",
xaxis = list(title ="tr"),
yaxis = list(title = "cc")) %>%
add_text(x=x, y=y, text=labs, hoverinfo='none', textposition = 'top', showlegend = FALSE,
textfont=list(size=20, color="black")) %>%
layout(margin = list(b=100, l=100),
xaxis = list(tickangle=15, title = "Lenght of exon", titlefont=list(size=30)),
yaxis = list(title = "Number of genes", titlefont=list(size=30)))
Run Code Online (Sandbox Code Playgroud)