Forgot the year on the plot:
n <- 100 x <- data.frame(time = seq(from = as.Date('2010-1-1') , to = as.Date('2012-1-1') , length = n ) , val = runif(n) ) plot(x$time, x$val, type = 'l', main = 'Default') # now plot with your own axis with the first character of month in the center # create sequence of start of month plot(x$time, x$val, type = 'l', main = 'Manual Labels', xaxt = 'n') monthTick <- seq(from = as.Date(format(min(x$time), "%Y-%m-1")) , to = as.Date(format(max(x$time), "%Y-%m-1")) , by = '1 month' ) # create tick marks axis(1, at = monthTick, labels = FALSE) # add months mtext(substring(months(monthTick), 1, 1) , at = monthTick + 15 , side = 1 ) # add the year yearTick <- seq(from = min(monthTick) , to = max(monthTick) , by = '1 year' ) mtext(format(yearTick, "%Y"), at = yearTick + 182, line = 1, side = 1) On Sun, Aug 25, 2013 at 6:01 PM, jim holtman <jholt...@gmail.com> wrote: > Try this: > > n <- 100 > x <- data.frame(time = seq(from = as.Date('2010-1-1') > , to = as.Date('2012-1-1') > , length = n > ) > , val = runif(n) > ) > plot(x$time, x$val, type = 'l', main = 'Default') > # now plot with your own axis with the first character of month in the > center > plot(x$time, x$val, type = 'l', main = 'Manual Labels', xaxt = 'n') > > # create sequence of start of month > monthTick <- seq(from = as.Date(format(min(x$time), "%Y-%m-1")) > , to = as.Date(format(max(x$time), "%Y-%m-1")) > , by = '1 month' > ) > > # create tick marks > axis(1, at = monthTick, labels = FALSE) > # add months > > mtext(substring(months(monthTick), 1, 1) > , at = monthTick + 15 > , side = 1 > ) > > > > On Sun, Aug 25, 2013 at 1:08 PM, Sudheer Joseph <sjo.in...@gmail.com>wrote: > >> Thank you, >> I rechecked it , I had attached the plot >> but it may have been blocked due to site policies. So here is the link. >> >> >> https://docs.google.com/file/d/0B3heUQNme7G5RUxhYkN3NUQzdlk/edit?usp=sharing >> >> >> On Sun, Aug 25, 2013 at 10:12 PM, jim holtman <jholt...@gmail.com> wrote: >> >>> There was not attached plot or data. Plot without the x-axis (probably >>> xaxt = 'n') and then use "axis" to create your own ticks. It would be >>> helpful if you had supplied data using 'dput'. >>> >>> >>> On Sun, Aug 25, 2013 at 11:09 AM, Sudheer Joseph <sjo.in...@gmail.com>wrote: >>> >>>> Attached is a plot with a time series. If I have a time series object >>>> in R. >>>> How do I get the plot in the attached format of time axis?. When I issue >>>> plot(ts) I get a time series plot with tic only for years. >>>> >>>> >>>> -- >>>> with best regards >>>> >>>> Sudheer >>>> >>>> >>>> ********************************************************************************** >>>> Dr. Sudheer Joseph >>>> >>>> Scientist >>>> >>>> INDIAN NATIONAL CENTRE FOR OCEAN INFORMATION SERVICES (INCOIS) >>>> MINISTRY OF EARTH SCIENCES, GOVERNMENT OF INDIA >>>> "OCEAN VALLEY" PRAGATHI NAGAR (BO) >>>> OPP.JNTU, NIZAMPET SO >>>> Andhra Pradesh, India. PIN- 500 090. >>>> TEl:+91-40-23044600(R),Tel:+91-9440832534(Mobile) >>>> Tel:+91-40-23886047(O),Fax:+91-40-23892910(O) >>>> E-mail: sudheer.jos...@yahoo.com; s...@incois.gov.in. >>>> Web- http://oppamthadathil.tripod.com >>>> --------------* --------------- >>>> "The ultimate measure of a man is >>>> not where he stands in moments of >>>> comfort and convenience, but where >>>> he stands at times of challenge and >>>> controversy." >>>> Martin Luther King, Jr. >>>> "What we have done for ourselves alone dies with us. >>>> What we have done for others and the world remains and is immortal." >>>> - Albert Pines >>>> >>>> ______________________________________________ >>>> R-help@r-project.org mailing list >>>> https://stat.ethz.ch/mailman/listinfo/r-help >>>> PLEASE do read the posting guide >>>> http://www.R-project.org/posting-guide.html >>>> and provide commented, minimal, self-contained, reproducible code. >>>> >>>> >>> >>> >>> -- >>> Jim Holtman >>> Data Munger Guru >>> >>> What is the problem that you are trying to solve? >>> Tell me what you want to do, not how you want to do it. >>> >> >> >> >> -- >> with best regards >> >> Sudheer >> >> >> ********************************************************************************** >> Dr. Sudheer Joseph >> >> Scientist >> >> INDIAN NATIONAL CENTRE FOR OCEAN INFORMATION SERVICES (INCOIS) >> MINISTRY OF EARTH SCIENCES, GOVERNMENT OF INDIA >> "OCEAN VALLEY" PRAGATHI NAGAR (BO) >> OPP.JNTU, NIZAMPET SO >> Andhra Pradesh, India. PIN- 500 090. >> TEl:+91-40-23044600(R),Tel:+91-9440832534(Mobile) >> Tel:+91-40-23886047(O),Fax:+91-40-23892910(O) >> E-mail: sudheer.jos...@yahoo.com; s...@incois.gov.in. >> Web- http://oppamthadathil.tripod.com >> --------------* --------------- >> "The ultimate measure of a man is >> not where he stands in moments of >> comfort and convenience, but where >> he stands at times of challenge and >> controversy." >> Martin Luther King, Jr. >> "What we have done for ourselves alone dies with us. >> What we have done for others and the world remains and is immortal." >> - Albert Pines >> > > > > -- > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > Tell me what you want to do, not how you want to do it. > -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.