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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:00:37+00:00 2026-05-29T22:00:37+00:00

Is there a automatic way of adding a second x axis bellow the first

  • 0

Is there a “automatic” way of adding a second x axis bellow the first one?

My data is similar to this:

A1=data.frame(dates=seq(as.Date("2000/1/1"), by="day", length.out=1080),obs=runif(1080,min=-10,max=15))
A2=data.frame(dates=seq(as.Date("2010/1/1"), by="day", length.out=1080),obs=runif(1080,min=-8,max=50))

par(new=T)
plot(A1,ylim=range(min(A1[,2],A2[,2]):max(A1[,2],A2[,2])))
par(new=F)
plot(A2,ylim=range(min(A1[,2],A2[,2]):max(A1[,2],A2[,2])))

The only solution I found was to make it by manually. I have multiple time series with the same length and I would like to overlay the observations and keep the x axis like this:

_________________________________________________
  |        |       |        |        |        |
2000     2001     2002     2003     2004     2005  
2010     2011     2012     2013     2014     2015
2020     2021     2022     2023     2024     2025
(...)

each time series with a different colour.

  • 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-05-29T22:00:38+00:00Added an answer on May 29, 2026 at 10:00 pm

    Automatically? Not that I know of.

    But I do know that you can (with some effort) do this by hand. For example:

    par(mar = c(10,4,4,2) + 0.1)
    plot(1:3,1:3,axes = FALSE,xlab = "")
    axis(1,1:3,labels = FALSE)
    mtext(c('2000','2001','2002'),side = 1,line = 1,at = 1:3,col = "red")
    mtext(c('2010','2011','2012'),side = 1,line = 2,at = 1:3,col = "blue")
    mtext(c('2000','2001','2002'),side = 1,line = 3,at = 1:3,col = "red")
    mtext(c('2010','2011','2012'),side = 1,line = 4,at = 1:3,col = "blue")
    axis(2)
    

    enter image description here

    I’ve increased the number of lines in the bottom margin to 10 by setting mar, to demonstrate how you’d ensure there’s enough room for each row of axis labels.

    Then you plot, omitting the axes, add the x axis with just the ticks, and then draw each row of text labels using mtext.

    If you didn’t need each row to be a different color, you could do this with one call to axis where the labels argument consists of a vector like c("2000\n2010\n2020","2001\n2011\n2021","2002\n2012\n2022") and then fiddling with padj to get them centered correctly.

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

Sidebar

Related Questions

is there a way to do this with automatic properties ? private IList<string> List;
Is there an automatic way in SQL Server 2005 to create a database from
Is there an automatic way to add base classes to Linq2Sql entities? I know
Is there an automatic way I can use to rename a pylons controller? If
When plotting a graph with a discontinuity/asymptote/singularity/whatever, is there any automatic way to prevent
I wonder whether there is any automatic way of determining (at least roughly) the
Is there a way in rst to have automatic header numbering ? That is
I would like to know if there is a way to disable automatic loading
Is there an automatic way to optimize inclusion of header files in C++, so
I understand the way wpf supports automatic updates of DataGrids and Listboxes (ie adding

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.