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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:06:38+00:00 2026-06-15T20:06:38+00:00

I wanted to plot time series data in R by using ggplot but I

  • 0

I wanted to plot time series data in R by using ggplot but I have faced with this error:

Error in continuous_scale(aesthetics, "date", identity, breaks = breaks,  : 
unused argument(s) (format = "%b-%Y")

Syntax:

ggplot(p29, aes(dt, ambtemp)) + geom_line() +
    scale_x_date(format = "%b-%Y") + xlab("") + ylab("Tempreture")

File Name: p29

  ambtemp                  dt surtemp
1   -1.14 2007-09-29 00:01:57  -2.712
2   -1.12 2007-09-29 00:03:57  -2.775
3   -1.33 2007-09-29 00:05:57  -2.712
4   -1.44 2007-09-29 00:07:57  -2.837
5   -1.54 2007-09-29 00:09:57  -2.775
6   -1.29 2007-09-29 00:11:57  -2.900
  • 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-15T20:06:39+00:00Added an answer on June 15, 2026 at 8:06 pm

    In function scale_x_date() you should write labels=date_format("%b-%Y"). Also column dt should be formatted as Date.

    library(scales)
    p29$dt=as.Date(p29$dt, format="%Y-%m-%d %H:%M:%S")    
    ggplot(p29, aes(dt, ambtemp)) + geom_line() +
    scale_x_date(labels=date_format ("%b-%Y")) + xlab("") + ylab("Tempreture")  
    

    To show hours and minutes, instead of function scale_x_date() you should use scale_x_datetime() and write labels=date_format("%H:%M"). To control breaks argument breaks=date_breaks() is used. Also column dt should be formatted as POSIXt.

    library(scales)
    p29$dt=strptime(p29$dt, "%Y-%m-%d %H:%M:%S")
    ggplot(p29, aes(dt, ambtemp)) + geom_line() +
    scale_x_datetime(breaks = date_breaks("5 min"),labels=date_format("%H:%M")) + xlab("") + ylab("Tempreture")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a plot like this: https://i.stack.imgur.com/zdike.png I need the data coordinates of points
I have a series of spectral data which I want to plot in a
I have a list of vectors which are time series of inequal length. My
I have several plt.plot instances and I wanted to only plt.show() certain objects. To
this is a small, but very annoying , glitch in my form. I have
Several times I have wanted to detect single keystrokes in R but have failed
I have a zoo with daily data that looks like this: > head(almorol) 1973-10-02
I created a histogram plot using data from a file and no problem. Now
This is a follow-up of this question . I wanted to plot multiple curves
I wanted to ask for any general idea about plotting this kind of plot

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.