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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:24:48+00:00 2026-06-13T10:24:48+00:00

I was trying to use ggplot to plot monthly data that looks like this

  • 0

I was trying to use ggplot to plot monthly data that looks like this

  count     date
      6 Oct 2010
     23 Nov 2010
     20 Dec 2010
     16 Jan 2011
     64 Oct 2011
     ...
    425 Jul 2012
    436 Aug 2012
    405 Sep 2012

where date is of yearmon class from the zoo package.

This was my call:

ggplot(data, aes(x=date, y=count))+geom_line()

and this error came up: Error: Discrete value supplied to continuous scale.

So ggplot doesn’t support the yearmon class, which is fine.

Then I tried to convert yearmon to Date. Now the data looks like this:

 count       date
     6 2010-10-01
    23 2010-11-01
    20 2010-12-01
    16 2011-01-01
    64 2011-10-01
   ...
   425 2012-07-01
   436 2012-08-01
   405 2012-09-01

and I made the same call, and this was the resulting plot (sorry about the href… new users aren’t allowed to post images)

There is a drop at the end of the plot that shouldn’t be there, because data$count had the similar values on the last few rows.

Does anyone have a good solution to this?

Thanks for reading,

Bill

  • 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-13T10:24:48+00:00Added an answer on June 13, 2026 at 10:24 am

    I am unable to recreate the problem with the line dropping unexpectedly on the right of the plot. Here is the code I used, and the output:

    library(ggplot2)
    
    dat = read.table(header=TRUE, colClasses=c("numeric", "Date"),
    text=" count       date
         6 2010-10-01
        23 2010-11-01
        20 2010-12-01
        16 2011-01-01
        64 2011-10-01
       425 2012-07-01
       436 2012-08-01
       405 2012-09-01")
    
    plot_1 = ggplot(dat, aes(x=date, y=count)) + geom_line()
    ggsave("plot_1.png", plot_1, height=4.5, width=4.5)
    

    enter image description here

    You might consider posting your data before and after the date conversion (using dput()) to help people reproduce your problem.

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

Sidebar

Related Questions

I have a data frame like this: Server Date Server Space 1 2010-01-30 server1
I'm trying to use a local variable in aes when I plot with ggplot.
I am trying to use geom_point to illustrate the count of my data. I
I've been trying to use ggplot2 to produce a plot similar to this R
I am need paint my image. I'm trying use JQuery in here this link:
I'm trying to use ggplot2 to create and label a scatterplot. The variables that
I am trying to figure out how to use grconvertX/grconvertX in ggplot. My ultimate
I am trying to display some information about the data below the plot created
I am trying to add geom_text labels to my mosaic plot below: that I
i'm trying use webview to load a image from sdcard i use this path

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.