Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9066301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:42:11+00:00 2026-06-16T16:42:11+00:00

I have a time series with multiple days of data. In between each day

  • 0

I have a time series with multiple days of data. In between each day there’s one period with no data points. How can I omit these periods when plotting the time series using ggplot2?

An artificial example shown as below, how can I get rid of the two periods where there’s no data?

code:

Time = Sys.time()+(seq(1,100)*60+c(rep(1,100)*3600*24, rep(2, 100)*3600*24, rep(3, 100)*3600*24))
Value = rnorm(length(Time))
g <- ggplot() 
g <- g + geom_line (aes(x=Time, y=Value))
g

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:42:12+00:00Added an answer on June 16, 2026 at 4:42 pm

    First, create a grouping variable. Here, two groups are different if the time difference is larger than 1 minute:

    Group <- c(0, cumsum(diff(Time) > 1))
    

    Now three distinct panels could be created using facet_grid and the argument scales = "free_x":

    library(ggplot2)
    g <- ggplot(data.frame(Time, Value, Group)) + 
      geom_line (aes(x=Time, y=Value)) +
      facet_grid(~ Group, scales = "free_x")
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an irregular(?) time series data points in a day as following Jun
I have a data frame containing multiple time series of returns, stored in columns.
I have a data.frame with multiple time series vectors against a date:time vector. I
There is a time series of 100 data points(say). I wish to assign symbols
I have a data frame with multiple time series identified by uniquer id's. I
I have a time series: dDate=seq(as.POSIXct(2012/1/1), as.POSIXct(2012/1/10), day) dDate [1] 2012-01-01 PST 2012-01-02 PST
I have a time series of two indexes, with each row representing the closing
I have a data.frame of a time series of data, I would like to
I have a variety of time-series data stored on a more-or-less georeferenced grid, e.g.
I have a (C#) genetic program that uses financial time-series data and it's currently

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.