Reputation: 11
friends!
If I plot a bar charts using plotly in R, by default I have no spacing between bars.
My questions are:
Thanks a lot!
Upvotes: 1
Views: 1790
Reputation: 37
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
Upvotes: 1