- 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 a staircase plot in R?
The simple staircase plot can be created by using geom_tile function of ggplot2 package. We just need to use the vector or the column for which we want to create the staircase plot in place of x and y as well. For example, if we have a column say x of an R data frame df then the staircase plot can be created as ggplot(df,aes(x,x))+geom_tile().
Example
Consider the below data frame:
> x<-1:10 > df<-data.frame(x) > df
Output
x 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10
Loading ggplot2 package and creating staircase plot:
> library(ggplot2) > ggplot(df,aes(x,x))+geom_tile()
Output
Creating a staircase plot using log function of x:
> ggplot(df,aes(x,log(x)))+geom_tile()
Output
- Related Articles
- How to create ACF plot in R?
- How to create a plot in R with gridlines using plot function?
- How to create a plot in R with a different plot window size using plot function?
- How to create correlation matrix plot in R?
- How to create a dot plot using ggplot2 in R?
- How to create a plot with cross sign in R?
- How to create a perpendicular arrow in base R plot?
- How to create a cumulative sum plot in base R?
- How to create a plot of binomial distribution in R?
- How to create a plot using rgb colors in R?
- How to create a plot in base R without margins?
- How to create a plot of Poisson distribution in R?
- How to create a plot of empirical distribution in R?
- How to create empty bar plot in base R?
- How to create density plot for categories in R?

Advertisements