- 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 create quantile regression plot with larger width of lines using ggplot2 in R?
To create quantile regression plot with larger width of lines using ggplot2 in R, we can follow the below steps −
First of all, create a data frame.
Then, use stat_quantile function with size argument and geom_point function of ggplot2 package to create quantile regression plot.
Example
Create the data frame
Let’s create a data frame as shown below −
x<-rpois(25,2) y<-rpois(25,5) df<-data.frame(x,y) df
Output
On executing, the above script generates the below output(this output will vary on your system due to randomization) −
x y 1 1 6 2 1 1 3 3 4 4 4 9 5 4 7 6 2 5 7 1 7 8 1 4 9 2 7 10 3 3 11 4 3 12 2 5 13 4 7 14 2 7 15 0 8 16 5 0 17 3 4 18 0 2 19 3 0 20 0 5 21 2 5 22 2 5 23 6 7 24 2 2 25 0 3
Create quantile regression plot with larger width of lines
Using stat_quantile function with size argument and geom_point function of ggplot2 package to create quantile regression plot for the data stored in data frame df −
x<-rpois(25,2) y<-rpois(25,5) df<-data.frame(x,y) library(ggplot2) ggplot(df,aes(x,y))+geom_point()+stat_quantile(formula=y~x,quantiles=c(0.25,0.50,0.75 ))
Output
Create quantile regression plot with larger width of lines
Using stat_quantile function with size argument and geom_point function of ggplot2 package to create quantile regression plot with larger width of lines for the data stored in data frame df −
x<-rpois(25,2) y<-rpois(25,5) df<-data.frame(x,y) library(ggplot2) ggplot(df,aes(x,y))+geom_point()+stat_quantile(formula=y~x,quantiles=c(0.25,0.50,0.75 ),size=2)
Output
- Related Articles
- Create multiple regression lines in a single plot using ggplot2 in R.
- How to create a line chart using ggplot2 with larger width in R?
- How to create multiple regression lines using ggplot2 in R?\n
- How to create a line chart in R using plot function with larger width?
- How to create a horizontal line in ggplot2 graph with larger width in R?
- How to create dotted vertical lines in a plot using ggplot2 in R?
- How to create normal quantile-quantile plot for a logarithmic model in R?
- How to create stacked plot with density using ggplot2 in R?
- How to plot the confidence interval of the regression model using ggplot2 with transparency in R?
- How to create bar plot with log values using ggplot2 in R?
- How to create a bar plot with ggplot2 using stat_summary in R?
- How to plot the regression line starting from origin using ggplot2 in R?
- How to create a dot plot using ggplot2 in R?
- How to create transparent bar plot using ggplot2 in R?
- How to create an empty plot using ggplot2 in R?
