如何在曲线上改变轴特征?(How to change axis features in plotly?)

编程入门 行业动态 更新时间:2024-10-26 08:29:50
如何在曲线上改变轴特征?(How to change axis features in plotly?)

我在剧情中有以下栏,我想:

从轴标签获取x轴标题,使它们不重叠 使Y轴标签更大 将条形值带到条形的顶部

我的代码是:

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

感谢您的意见 :)

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

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 :)

最满意答案

问题1:使x轴标题远离轴标签,使它们不重叠 在layout使用margin = list(b=100, l=100)设置适当的边距可以解决此问题。 问题2:使Y轴标签更大。 在layout使用xaxis = list(titlefont=list(size=30)) 问题3:将条形值带到条形图的顶部。 使用带有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)))

在此处输入图像描述

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

enter image description here

更多推荐

本文发布于:2023-08-05 21:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437758.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:曲线   特征   如何在   change   features

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!