- 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
Create ggplot2 graph with darker axes labels, lines and titles in R
To create a ggplot2 graph with darker axes labels, darker lines, and dark titles, we can use theme_classic function of ggplot2 package with base_size argument set to a larger value.
For Example, if we have a data frame called df that contains two columns say x and y then we can create the scatterplot between x and y using ggplot2 with darker axes labels, darker lines, and dark titles by using the below command −
ggplot(df,aes(x,y))+geom_point()+theme_classic(base_size=22)
Example
Following snippet creates a sample data frame −
x<-rpois(20,5) y<-rpois(20,2) df<-data.frame(x,y) df
The following dataframe is created
x y 1 9 4 2 2 1 3 4 4 4 7 0 5 7 0 6 3 1 7 3 1 8 3 1 9 3 0 10 6 1 11 5 1 12 6 4 13 6 1 14 4 1 15 7 1 16 3 3 17 0 3 18 4 4 19 4 2 20 3 1
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<-rpois(20,5) y<-rpois(20,2) 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 darker axes labels, darker lines, and dark titles on the above created data frame, add the following code to the above snippet −
x<-rpois(20,5) y<-rpois(20,2) df<-data.frame(x,y) library(ggplot2) ggplot(df,aes(x,y))+geom_point()+theme_classic(base_size=20)
Output
If you execute all the above given snippets as a single program, it generates the following Output −
- Related Articles
- Create a ggplot2 graph without axes labels, axes titles and ticks in R.
- Create a graph using ggplot2 without axes ticks and axes labels.
- Create darker gridlines in theme_bw for a ggplot2 graph in R.
- How to create a bar graph using ggplot2 without horizontal gridlines and Y-axes labels in R?
- R Programming how to display both axes’ labels of a ggplot2 graph in italics?
- How to display axes ticks and labels inside the plot using ggplot2 in R?
- How to extract axes labels for the plot drawn using ggplot2 in R?
- How to create boxplot in base R without axes labels?
- Create ggplot2 graph with reversed Y-axis and X-axis on top in R.
- How to display base R plot axes titles in italics?
- How to create a plot in base R with tick marks but excluding axes lines?
- Create a graph without background panel using ggplot2 in R.
- How to create a horizontal line in ggplot2 graph with larger width in R?
- How to create a horizontal line in ggplot2 graph with different color in R?
- How to create a graph in R using ggplot2 with all the four quadrants?
