- 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 change the border color of points in a scatterplot created with ggplot2 in R?
Aesthetics is an essential part of a plot whether it is a scatterplot or any other plot. When we create a scatterplot with ggplot function of ggplot2 package, the border of the points is black if we fill the points with the sequence of a color but we can change these borders to any other color by using colour argument.
Example
Consider the below data frame
Rate <-1:10 Score <-10:1 S.no <-c(2,5,7,8,9,12,15,18,25,27) df <-data.frame(Rate,Score,S.no) df
Output
Rate Score S.no 1 1 10 2 2 2 9 5 3 3 8 7 4 4 7 8 5 5 6 9 6 6 5 12 7 7 4 15 8 8 3 18 9 9 2 25 10 10 1 27 > library(ggplot2)
Creating the scatterplot without defining border color −
ggplot(df,aes(Rate,Score))+geom_point(aes(fill=S.no),pch=21,size=10)
Output
Creating the scatterplot with red border color −
ggplot(df,aes(Rate,Score))+geom_point(aes(fill=S.no),pch=21,size=10,colour="red")
Output
Creating the scatterplot with green border color −
ggplot(df,aes(Rate,Score))+geom_point(aes(fill=S.no),pch=21,size=10,colour="green")
Output
- Related Articles
- How to change the color of points in a scatterplot using ggplot2 in R?
- How to change the color of points for ggplot2 scatterplot using color brewer in R?
- How to display NA group values in scatterplot created with ggplot2 using color brewer in R?
- How to change the plot border color of a ggplot2 graph in R?
- How to color scatterplot points based on a threshold using ggplot2 in R?
- How to change the default type of points for scatterplot using ggplot2 in R?
- How to display ID column values in a scatterplot created with ggplot2 in R?
- Change the color of legend element border using ggplot2 in R.
- How to create a scatterplot in R using ggplot2 with transparency of points?
- How to create a scatterplot with dark points using ggplot2 in R?
- How to create a scatterplot using ggplot2 with different shape and color of points based on a variable in R?
- How to create a scatterplot in R using ggplot2 with different designs of points?
- How to create a scatterplot with low intensity of points using ggplot2 in R?
- How to change the bars color to grey shade of a bar graph created by using ggplot2 in R?
- How to add a vertical line with some value on a scatterplot created by ggplot2 in R?

Advertisements