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 7958567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:26:32+00:00 2026-06-04T04:26:32+00:00

Possible Duplicate: Plot dates on the x axis and time on the y axis

  • 0

Possible Duplicate:
Plot dates on the x axis and time on the y axis with ggplot2

I have these data,

Arrival Date
7:50    Apr-19
7:45    Apr-20
7:30    Apr-23
7:30    Apr-24
7:55    Apr-25
7:20    Apr-26
7:30    Apr-27
7:50    Apr-28
8:00    Apr-30
7:45    May-2
8:30    May-3
8:06    May-4
8:25    May-7
7:35    May-8
7:45    May-9
8:02    May-10
7:53    May-11
8:39    May-14
8:14    May-15
8:08    May-16
8:27    May-17
8:20    May-18
12:00   Apr-19
12:00   Apr-20
12:00   Apr-23
12:00   Apr-24
12:00   Apr-25
12:00   Apr-26
12:00   Apr-27
12:00   Apr-28
11:50   Apr-30
12:00   May-2
11:45   May-3
11:50   May-4
12:00   May-7
11:50   May-8
11:55   May-9
12:10   May-10
11:53   May-11
11:54   May-14
11:40   May-15
11:54   May-16
11:45   May-17
12:00   May-18

And I want to plot it using ggplot,

This is what I did,

OJT <- read.csv(file = "Data.csv", header = TRUE)

qplot(Date,Arrival, data = OJT, xlab = expression(bold("Date")), ylab = expression(bold("Time"))) + theme_bw() + opts(axis.text.x=theme_text(angle=90)) +geom_point(size = 2, colour = "black", fill = "red", pch = 21)

And here is the output

enter image description here

As you can see, the time and date is not arrange. I want the time to start from 7:00 am to 12:20 pm, and the date from April 19 to May 18. I tried using

as.Date(strptime(OJT$Date,"%m-%dT"))

But still I don’t get the right plot.

And I can’t find similar problems through the internet.

Any idea to help me solve this.

Thanks

  • 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-04T04:26:33+00:00Added an answer on June 4, 2026 at 4:26 am

    I will try a different approach with some wrangling in lubridate. Target plot:

    date-hour plot

    The code, including your data:

    library("ggplot2")
    library("lubridate")
    
    df <- read.table(text = "Arrival Date
    7:50    Apr-19
    7:45    Apr-20
    7:30    Apr-23
    7:30    Apr-24
    7:55    Apr-25
    7:20    Apr-26
    7:30    Apr-27
    7:50    Apr-28
    8:00    Apr-30
    7:45    May-2
    8:30    May-3
    8:06    May-4
    8:25    May-7
    7:35    May-8
    7:45    May-9
    8:02    May-10
    7:53    May-11
    8:39    May-14
    8:14    May-15
    8:08    May-16
    8:27    May-17
    8:20    May-18
    12:00   Apr-19
    12:00   Apr-20
    12:00   Apr-23
    12:00   Apr-24
    12:00   Apr-25
    12:00   Apr-26
    12:00   Apr-27
    12:00   Apr-28
    11:50   Apr-30
    12:00   May-2
    11:45   May-3
    11:50   May-4
    12:00   May-7
    11:50   May-8
    11:55   May-9
    12:10   May-10
    11:53   May-11
    11:54   May-14
    11:40   May-15
    11:54   May-16
    11:45   May-17
    12:00   May-18", header=TRUE)
    
    df$Date <- paste('2012-',df$Date, sep='')
    df$Full <- paste(df$Date, df$Arrival, sep=' ')
    df$Full <- ymd_hm(df$Full)
    df$decimal.hour <- hour(df$Full) + minute(df$Full)/60
    
    p <- ggplot(df, aes(x=Full, y=decimal.hour)) +
        geom_point()
    p
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Automatically plot different colored lines in MATLAB I have the following data
Possible Duplicate: List of ggplot2 options? I have a pretty basic question on ggplot2.
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: Plotting 4 curves in a single plot, with 3 y-axes I have
Possible Duplicate: ggplot2: Adding Regression Line Equation and R2 on graph I'm graphing data
Possible Duplicate: Why does ReSharper want to use 'var' for everything? I have ReSharper
Possible Duplicate: Shading a kernel density plot between two points I want to produce
Possible Duplicate: core-plot remove decimal points from axis labels I 'am building a Scatterplot
Possible Duplicate: How to choose the numbers shown on the axes of a plot
Possible Duplicate: regex for URL including query string I have a text or message.

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.