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

  • Home
  • SEARCH
  • 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 9146119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:40:44+00:00 2026-06-17T10:40:44+00:00

I have two set of time series data. I would like to plot them

  • 0

I have two set of time series data. I would like to plot them with respect to the time and date. Moreover, they are number of attributes (-1 or 1) for the corresponding time under the title of outlier and they should be presented with a symbol where outlier=”-1″ on the plot. Moreover, another problem in my code is in the Legend the title of the legend and one of the contents of the legend appeared similarly.

true   pred   outlier   dtt 
0.05       0    1   9/29/2007 0:00  
-0.33      0    1   9/29/2007 1:00  
-0.41      0    1   9/29/2007 2:00  
-0.69      0    1   9/29/2007 3:00  
-0.68      0    1   9/29/2007 4:00  
-0.43   -0.53   1   9/29/2007 5:00  
-0.12   -0.23   1   9/29/2007 6:00  
0.15    0.16    1   9/29/2007 7:00  
0.56    0.39    1   9/29/2007 8:00  
0.98    0.87    1   9/29/2007 9:00  
1.18    1.27    1   9/29/2007 10:00 
2.14    1.31    1   9/29/2007 11:00 
4.12    2.87    1   9/29/2007 12:00 
5.59    5.43    1   9/29/2007 13:00 
6.90    6.52    1   9/29/2007 14:00 
6.40    7.80    1   9/29/2007 15:00 
5.88    5.78    1   9/29/2007 16:00 
6.14    5.58    1   9/29/2007 17:00 
4.61    6.20    -1  9/29/2007 18:00 
5.15    6.20    1   9/29/2007 19:00 
2.74    4.54    -1  9/29/2007 20:00 
4.66    4.54    1   9/29/2007 21:00 
5.10    4.74    1   9/29/2007 22:00 
4.79    5.53    1   9/29/2007 23:00 

Applied code:

ggplot(second_data_results_node25, aes( second_data_results_node25$dtt)) +
    geom_line(aes(y = second_data_results_node25$true, colour = "TRUE")) + 
    geom_line(aes(y = second_data_results_node25$pred, colour = "Prediction"))
  • 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-17T10:40:45+00:00Added an answer on June 17, 2026 at 10:40 am

    Inorder to draw using ggplot2, you’ll have to shape your data accordingly. Since you have two variables, you could melt them (I use reshape2 here to melt) and use group in ggplot2 as follows:

    require(ggplot2)
    require(reshape2)
    df <- structure(list(true = c(0.05, -0.33, -0.41, -0.69, -0.68, -0.43, 
    -0.12, 0.15, 0.56, 0.98, 1.18, 2.14, 4.12, 5.59, 6.9, 6.4, 5.88, 
    6.14, 4.61, 5.15, 2.74, 4.66, 5.1, 4.79), pred = c(0, 0, 0, 0, 
    0, -0.53, -0.23, 0.16, 0.39, 0.87, 1.27, 1.31, 2.87, 5.43, 6.52, 
    7.8, 5.78, 5.58, 6.2, 6.2, 4.54, 4.54, 4.74, 5.53), outlier = c(1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, -1L, 1L, -1L, 1L, 1L, 1L), dtt = c("9/29/2007 0:00", "9/29/2007 1:00", 
    "9/29/2007 2:00", "9/29/2007 3:00", "9/29/2007 4:00", "9/29/2007 5:00", 
    "9/29/2007 6:00", "9/29/2007 7:00", "9/29/2007 8:00", "9/29/2007 9:00", 
    "9/29/2007 10:00", "9/29/2007 11:00", "9/29/2007 12:00", "9/29/2007 13:00", 
    "9/29/2007 14:00", "9/29/2007 15:00", "9/29/2007 16:00", "9/29/2007 17:00", 
    "9/29/2007 18:00", "9/29/2007 19:00", "9/29/2007 20:00", "9/29/2007 21:00", 
    "9/29/2007 22:00", "9/29/2007 23:00")), .Names = c("true", "pred", 
    "outlier", "dtt"), class = "data.frame", row.names = c(NA, -24L
    ))
    
    df.m <- melt(df, names(df)[3:4], names(df)[1:2])
    df.m$outlier <- factor(df.m$outlier)
    df.m$dtt <- strptime(as.character(df.m$dtt), format = "%m/%d/%Y %H:%M")
    p <- ggplot(df.m, aes(x = dtt, y = value, group = variable, color = variable))
    p <- p + geom_point(aes(shape = outlier))
    p <- p + geom_line()
    p <- p + theme(axis.text.x = element_text(angle = 90, hjust = 1))
    p
    

    Result_ggplot2

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

Sidebar

Related Questions

I have two set of time series data. I would like to plot them
I have two set of samples that are time independent. I would like to
I have two Models - Users and Restaurants. They can set tweets like status
I have two sets of data with different time stamps. One set of data
I have a large time series data set, which I've used xts to summarize
I have a large time-series set of data at 30 minute intervals and trying
I have two tables set up in phpmyadmin- table userid and table data. The
I have a two models set up like this: class User < ActiveRecord::Base #
I have two results from a data set. I want to add both results
I have set up a Core Data model where I have two objects, say

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.