
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display Two Equal Signs in R using ggplot2
To display two equal signs using ggplot2, we can follow the below steps −
- First of all, create a data frame.
- Create a scatterplot(you can create any other plot).
- Display two equal signs using annotate function
Create the data frame
Let's create a data frame as shown below −
x<-sample(1:100,25) y<-sample(1:100,25) df<-data.frame(x,y) df
On executing, the above script generates the below output(this output will vary on your system due to randomization) −
x y 1 1 12 2 74 54 3 39 9 4 60 6 5 86 7 6 29 80 7 90 92 8 42 93 9 43 99 10 82 69 11 6 24 12 45 53 13 8 39 14 12 47 15 17 74 16 35 28 17 40 83 18 27 49 19 88 3 20 33 23 21 48 59 22 5 97 23 49 31 24 68 13 25 96 75
Create the scatterplot
Loading ggplot2 package and creating scatterplot between x and y −
x<-sample(1:100,25) y<-sample(1:100,25) df<-data.frame(x,y) library(ggplot2) ggplot(df,aes(x,y))+geom_point()
Output
Create scatterplot with two equal signs inside the plot
Use annotate function of ggplot2 package to display two equal signs inside the plot −
x<-sample(1:100,25) y<-sample(1:100,25) df<-data.frame(x,y) library(ggplot2) ggplot(df,aes(x,y))+geom_point()+annotate("text",x=75,y=75,label=(paste0("X==~Y==5 0")),parse=TRUE)
Output
Advertisements