- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- 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

If we have a vector that contains dates as sequence that needs to be plotted on the X-axis and another vector for the response then the plot can be simply created by using the plot function. In the plot function, we would need to pass the dates as the first argument and the response vector as the second argument. Check ou the examples below to understand how it works.

x<-rpois(10,5) x

[1] 4 7 4 4 6 4 3 4 9 5

dates<-seq(as.Date("25/11/2020",format="%d/%m/%Y"),by="days",length=length(x)) dates

[1] "2020-11-25" "2020-11-26" "2020-11-27" "2020-11-28" "2020-11-29" [6] "2020-11-30" "2020-12-01" "2020-12-02" "2020-12-03" "2020-12-04"

plot(dates,x)

y<-sample(0:9,10,replace=TRUE) dates<-seq(as.Date("01/01/2020",format="%d/%m/%Y"),by="days",length=length(x)) plot(dates,y)

- Related Questions & Answers
- How to create a plot with tick marks between X-axis labels in base R?
- How to display raise to the power on X-axis in base R plot?
- How to create a plot with reversed Y-axis labels in base R?
- How to display X-axis labels inside the plot in base R?
- How to plot values with log scales on x and y axis or on a single axis in R?
- How to plot data against specific dates on the X-axis using Matplotlib?
- How to create bar plot in base R with different limits for Y-axis?
- How to create a plot of quadratic regression with fitted values against X in base R?
- How to use mtext function to create the X-axis labels in base R?
- How to create a bar plot using ggplot2 with percentage on Y-axis in R?
- How to plot the X-axis labels on the upper-side of the plot in R?
- How to create a plot with dashed regression line in base R?
- How to create vertical line for X variable at median in base R plot
- Plotting dates on the X-axis with Python's Matplotlib
- How to create a plot in base R without margins?

Advertisements