- 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 increase the width of the X-axis line for a ggplot2 graph?
To increase the width of the X-axis line for a ggplot2 graph in R, we can use theme function where we can set the axis.line.x.bottom argument size to desired size with element_line.
Check out the below Example to understand how it can be done.
Example
Following snippet creates a sample data frame −
x<-sample(0:9,20,replace=TRUE) y<-sample(0:9,20,replace=TRUE) df<-data.frame(x,y) df
The following dataframe is created
x y 1 4 5 2 5 0 3 5 3 4 7 4 5 1 9 6 0 6 7 6 0 8 9 7 9 6 5 10 5 3 11 2 8 12 3 2 13 5 1 14 1 2 15 8 2 16 6 5 17 5 2 18 1 2 19 9 4 20 9 2
To load ggplot2 package and create scatterplot between x and y on the above created data frame, add the following code to the above snippet −
x<-sample(0:9,20,replace=TRUE) y<-sample(0:9,20,replace=TRUE) df<-data.frame(x,y) library(ggplot2) ggplot(df,aes(x,y))+geom_point()
Output
If you execute all the above given snippets as a single program, it generates the following Output −
To create scatterplot between x and y with larger width of X-axis line on the above created data frame, add the following code to the above snippet −
x<-sample(0:9,20,replace=TRUE) y<-sample(0:9,20,replace=TRUE) df<-data.frame(x,y) library(ggplot2) ggplot(df,aes(x,y))+geom_point()+theme(axis.line.x.bottom=element_line(size=2))
Output
If you execute all the above given snippets as a single program, it generates the following Output −
- Related Articles
- Change the color of X-axis line for a graph using ggplot2.
- How to increase the length of Y-axis values for ggplot2 graph in R?
- How to increase the width of the median line in boxplot using ggplot2 in R?
- How to increase the X-axis labels font size using ggplot2 in R?
- How to increase the width of axes using ggplot2 in R?
- How to create a horizontal line in ggplot2 graph with larger width in R?
- How to increase the axes tick width using ggplot2 in R?
- How to represent all values of X-axis or Y-axis on the graph in R using ggplot2 package?
- How to increase the width of the lines in the boxplot created by using ggplot2 in R?
- Create ggplot2 graph with reversed Y-axis and X-axis on top in R.
- How to write a long line for the X-label of a scatterplot in R using ggplot2?
- How to increase the X-axis length of histogram in base R?
- How to shift a graph along the X-axis in matplotlib?
- How to increase the line thickness of a Seaborn Line?
- How to align the bars of a barplot with the X-axis using ggplot2 in R?
