- 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 remove ticks in a plot created by using gglot2 in R?
In a plot created by using ggplot2, the axes values are generated with tick marks such as representing X-axis labels from 1 to 10 and Y-axis labels from 10 to 1 but we can get rid of this tick marks by using theme function. If we want to create a plot without ticks then we just need to add the following code to the plot code.
theme(axis.ticks.x=element_blank(),axis.ticks.y=element_blank())
Example
Consider the below data frame.
> set.seed(321) > x<-rnorm(20,1,0.025) > y<-rnorm(20,5,1.35) > df<-data.frame(x,y) > df
Output
x y 1 1.0426226 6.238295 2 0.9821990 4.855467 3 0.9930504 6.334253 4 0.9970088 3.552478 5 0.9969010 3.976679 6 1.0067046 5.128251 7 1.0181710 1.853243 8 1.0058284 5.563647 9 1.0084778 3.487558 10 0.9862021 4.359176 11 1.0086925 2.933944 12 1.0371148 5.561215 13 1.0047081 5.856167 14 1.0610815 6.661644 15 0.9711640 4.791339 16 0.9798832 5.154628 17 1.0114017 1.994545 18 1.0105083 7.208317 19 1.0144396 4.784917 20 1.0111589 5.038161
Loading ggplot2 package and creating a point chart between x and y.
> library(ggplot2) > ggplot(df,aes(x,y))+geom_point()
Output
Creating point chart using ggplot2 without ticks on the axes.
Example
> ggplot(df,aes(x,y))+geom_point()+theme(axis.ticks.x=element_blank(),axis.ticks.y=element_blank())
Output
- Related Articles
- How to remove the boxes around legend of a plot created by ggplot2 in R?
- How to add a citation in a plot created by using ggplot2 in R?
- How to change the background color of a plot created by using plot function in R?
- How to add a mathematical expression in axis label in a plot created by using plot function in R?
- How to change legend values in a bar plot created by using ggplot2 in R?
- How to display regression slope using model in a plot created by ggplot2 in R?
- How to display regression intercept using model in a plot created by ggplot2 in R?
- How to highlight text inside a plot created by ggplot2 using a box in R?
- How to remove the border of the legend of a chart created by plot function in R?
- How to make all text size same in a plot created by using ggplot2 in R?
- How to align the text horizontally in a bar plot created by using ggplot2 in R?
- How to extract data from a plot created by ggplot2 in R?
- How to reduce the size of the area covered by legend in R for a plot created by using plot function?
- How to change the title of a graph to italic created by using plot function in R?
- How to change the angle of annotated text in plot created by using ggplot2 in R?

Advertisements