- 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 display long X-axis labels in a bar chart using plotly in R?
Plotly in R is a package specifically designed to create highly-interactive and publication-quality charts. The chart can be created by using plot_ly function of the package and there are three main arguments of plot_ly defined as x, y, and type, where x refers to the X-axis, y refers to the Y-axis and type refers to the chart type but the axes values are stored in a data frame or itself a shared.
Example
Loading plotly package:
> library(plotly)
Consider the below data frame:
> x<-c("United States of America","United Kingdom","Republic of China") > y<-c(501,510,505) > df<-data.frame(x,y) > df
Output
x y 1 United States of America 501 2 United Kingdom 510 3 Republic of China 505
Creating the bar plot for x:
Example
> plot_ly(x=x,y=y,type="bar")%>%layout(xaxis=list(tickangle=45))
Output
Warning message: `arrange_()` is deprecated as of dplyr 0.7.0. Please use `arrange()` instead. See vignette('programming') for more help This warning is displayed once every 8 hours. Call `lifecycle::last_warnings()` to see where this warning was generated.
Here it is showing a warning but it is not related to our chart hence there is no problem in ignoring it.
Output
- Related Articles
- How to create a bar chart using plotly in R?
- How to display positive sign for X-axis labels in R using ggplot2?
- How to hide the Y-axis tick labels on a chart in Python Plotly?
- How to create plotly bar chart with negative values in R?
- How to display X-axis labels inside the plot in base R?
- How to display X-axis labels with dash in base R plot?
- How to show all X-axis labels in a bar graph created by using barplot function in R?
- How to create pie chart using plotly in R?
- How to decrease the width of bars for plotly bar chart in R?
- How to rotate X-axis tick labels in Pandas bar plot?
- How to display X-axis tick marks as minimum and maximum only without their values using plotly in R?
- How to create plotly bar chart with values on top of bars in R?
- How to create a dendrogram without X-axis labels in R?
- How to increase the X-axis labels font size using ggplot2 in R?
- How to display count on Y-axis for line chart using ggplot2 in R?

Advertisements