如何在情节中更改轴特征?情节、特征、如何在

由网友(他的爱っ我的情)分享简介:I have the following bar in plotly and I want to :get the x-axis title away from the axis label so they dont overlapmake the Y-axis labels biggerbring the ba...

I have the following bar in plotly and I want to :

get the x-axis title away from the axis label so they dont overlap make the Y-axis labels bigger bring the bar values to the top of bars

有哪些修改PDF文档中文字的方法

My code is :

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 = " "))

Thanks for your comments :)

解决方案

Question 1: get the x-axis title away from the axis label so they dont overlap This problem can be solved setting proper margins with margin = list(b=100, l=100) in layout. Question 2: make the Y-axis labels bigger. Use xaxis = list(titlefont=list(size=30)) in layout Question 3: bring the bar values to the top of bars. Use add_text with textposition = '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)))

阅读全文

相关推荐

最新文章