简体   繁体   English

在R中Plotly:如何增加吧之间的空间?

[英]Plotly in R: how to increase the space between bars?

friends! 朋友们!

If I plot a bar charts using plotly in R, by default I have no spacing between bars. 如果我在R中使用plotly绘制条形图,默认情况下,条形之间没有间距。

My questions are: 我的问题是:

  1. How to increase the space between bars? 如何增加酒吧之间的空间? (see the pic) (见图)
  2. How to avoid overlapping of text and bars? 如何避免文本和栏的重叠? (see the pic) (见图)

Thanks a lot! 非常感谢!

插图

This can happen when using a numeric x axis... try putting as.factor(VARIABLE) 使用数字x轴时会发生这种情况...尝试输入as.factor(VARIABLE)

example: count the number of rows that contain the graduating class of the df = data frame you are plotting; 示例:计算包含您正在绘制的df =数据框的渐变类的行数; x = variable you are plotting x =您正在绘制的变量

plot_ly(df, x = df$x) plot_ly(df,x = df $ x)

 -this gives you a messy looking blob

plot_ly(df, x = as.factor(df$x)) plot_ly(df,x = as.factor(df $ x))

 -now it is known that your x axis is a factor, it will separate each value and break it up with a space in between

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM