简体   繁体   中英

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.

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)

example: count the number of rows that contain the graduating class of the df = data frame you are plotting; x = variable you are plotting

plot_ly(df, x = df$x)

 -this gives you a messy looking blob

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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