- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to decrease the width of bars for plotly bar chart in R?
To decrease the width of bars for plotly bar chart, we can use layout function and set the autosize argument to FALSE.
For example, if we have a data frame called that contains a categorical column C and a numerical column Count then bar chart with decreased width of the bars can be created by using the below command −
plot_ly(df,x=x,y=y,type="bar")%>%layout(autosize=F)
Example
Following snippet creates a sample data frame −
x<-LETTERS[1:3] y<-c(24,27,25) df<-data.frame(x,y) df
Output
The following dataframe is created −
x y 1 A 24 2 B 27 3 C 25
To load plotly package and create bar chart for data in df, add the following code to the above snippet −
library(plotly) plot_ly(df,x=x,y=y,type="bar")
Output
If you execute all the above given snippets as a single program, it generates the following output −
Now, to create bar chart for data in df with decreased width of bars (This will be better understood after application), add the following code to the above snippet −
plot_ly(df,x=x,y=y,type="bar")%>%layout(autosize=FALSE)
Output
If you execute all the above given snippets as a single program, it generates the following output −
- Related Articles
- How to create plotly bar chart with values on top of bars in R?
- How to change the order of bars in bar chart in R?
- How to create a bar chart using plotly in R?
- How to create plotly bar chart with negative values in R?
- How to create varying width bar chart using barplot function in R?
- How to create multiple bar plots for varying categories with same width bars using ggplot2 in R?
- How to determine the order of bars in a matplotlib bar chart?
- How to display long X-axis labels in a bar chart using plotly in R?
- How to remove gaps between bars in Matplotlib bar chart?
- How to create pie chart using plotly in R?
- How to create a horizontal bar chart using ggplot2 with labels at inside end of the bars in R?
- How to Adjust a Bar Chart to Make the Bars Wider in Excel?
- How do I get all the bars in a Matplotlib bar chart?
- How to sort bars in increasing order in a bar chart in matplotlib?
- How to create a bar plot with bars for missing values in R?
