[R] Plotting time vs number

John Kane jrkrideau at inbox.com
Thu Aug 29 16:30:31 CEST 2013


Please use dput() to supply data. It's a lot easier for readers to just copy and paste into R.

I have no idea of what variables are associated with the columns below.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: mohan.radhakrishnan at polarisft.com
> Sent: Thu, 29 Aug 2013 09:49:36 +0530
> To: jholtman at gmail.com
> Subject: Re: [R] Plotting time vs number
> 
> Hi,
> 
> plot(strptime(data$Time,"%H:%M:%S"),data$Kbytes,pch=0,type="b",col =
> "red", col.axis="red", ylab="", xlab="",las=2,lwd=2.5,cex.axis=1.5)
> title("",cex.main=3,xlab="Seconds", line=5.2,ylab="Kbytes", cex.lab=2,1)
> 
> Hope I am not simplifying this in a bad way. These  lines plot everything
> properly except the number of labels on the x-axis.
> 
> The plots are all there but the x=axis labels are not there. The graph
> labels are only '12:30', '13:30' and '14:30'
> 
> I think I need to use your code to get all the values.
> 
> 13:18:45        2691296 1601996 1584936
> 13:20:25        2691296 1603548 1586488
> 13:22:05        2691296 1603556 1586496
> 13:23:45        2691296 1606760 1589700
> 13:25:25        2691296 1611020 1593960
> 13:27:05        2691296 1614348 1597288
> 13:28:45        2691296 1614356 1597296
> 13:30:25        2691296 1614380 1597320
> 13:32:05        2691296 1614388 1597328
> 13:33:45        2691296 1614392 1597332
> 13:35:25        2691296 1614408 1597352
> 13:37:05        2691296 1614416 1597356
> 13:38:45        2691296 1614444 1597384
> 13:40:26        2691296 1614624 1597564
> 13:42:06        2691296 1614716 1597660
> 13:43:46        2691296 1614740 1597680
> 13:45:26        2691296 1614744 1597684
> 13:47:06        2756832 1631728 1614668
> 13:48:46        2756832 1631768 1614708
> 13:50:26        2756832 1631892 1614832
> 
> >>Tell me what you want to do, not how you want to do it.
> 
> If I don't show working code I don't get any response from the forum. So
> I
> need basic code to show how it works :-)
> 
> Thanks,
> Mohan
> 
> 
> 
> From:   jim holtman <jholtman at gmail.com>
> To:     mohan.radhakrishnan at polarisft.com
> Cc:     Jannis <bt_jannis at yahoo.de>, R mailing list
> <r-help at r-project.org>, r-help-bounces at r-project.org
> Date:   08/29/2013 01:32 AM
> Subject:        Re: [R] Plotting time vs number
> 
> 
> 
> What you need to do is to create the plot without an x-axis (xaxt =
> 'n') and then add your own values on the axis with 'axis'
> 
> 
> x <- read.table(text = "      Time  Kbytes     RSS Dirty_Mode
> 1 11:42:02 2691296 1599796    1582736
> 2 11:43:42 2691396 1599804    1582744
> 3 11:45:22 2691496 1599804    1582744
> 4 11:47:02 2691596 1599812    1582752
> 5 11:48:42 2691696 1599816    1582756
> 6 11:50:22 2691796 1599820    1582760", as.is = TRUE, header = TRUE)
> x$tod <- as.POSIXct(paste('2013-08-28', x$Time))
> plot(x$tod,x$Kbytes,type="b",col = "blue",  ylab="", xaxt = 'n',
> xlab="",las=2,lwd=2.5, lty=1,cex.axis=1.5)
> # now plot you times
> axis(1, at = x$tod, labels = x$Time, las = 2)
> 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.
> 
> 
> On Wed, Aug 28, 2013 at 8:35 AM,  <mohan.radhakrishnan at polarisft.com>
> wrote:
>> Hi,
>> 
>> plot(strptime(data$Time,"%H:%M:%S"),data$Kbytes,type="l",col = "blue",
>> ylab="", xlab="",las=2,lwd=2.5, lty=1,cex.axis=1.5)
>> 
>> strptime functions draws a proper graph but now all the time values are
>> not in the x-axis.
>> 
>>> 1 11:42:02 2691296
>>> 2 11:43:42 2691396
>>> 3 11:45:22 2691496
>>> 4 11:47:02 2691596
>>> 5 11:48:42 2691696
>> 
>> I mean that each time value is not shown. It shows only a few values.
> Each
>> individual pair is not plotted.
>> 
>> Thanks.
>> 
>> 
>> 
>> From:   mohan.radhakrishnan at polarisft.com
>> To:     Jannis <bt_jannis at yahoo.de>
>> Cc:     r-help at r-project.org, r-help-bounces at r-project.org
>> Date:   08/28/2013 05:39 PM
>> Subject:        Re: [R] Plotting time vs number
>> Sent by:        r-help-bounces at r-project.org
>> 
>> 
>> 
>> Hi Jannis,
>> 
>> I have tried that. It doesn't work. Jumps are not there in my other
> graphs
>> 
>> using numbers. Does this anything to do with time series ?
>> 
>> Can I just convert this time representation into milliseconds and plot
> the
>> 
>> graph ? The x-axis should still show this time format though(names.arg ?
>> ).
>> 
>> 
>> this.dir <- dirname(parent.frame(2)$ofile)
>> setwd(this.dir)
>> 
>> 
>> data = read.table("D:\\Log analysis\\pmapdata-node1.1",header=F)
>> colnames(data) <- c("Time","Kbytes","RSS","Dirty Mode")
>> 
>> 
>> png(
>>   "pmapanalysis4705.png",
>>    width = 2224, height = 768)
>> par(mar=c(5, 6, 5, 8) + 0.1)
>> 
>> plot(data$Time,names.org="Test",data$Kbytes,type="b",col = "blue",
>> ylab="", xlab="",las=2,lwd=2.5, lty=1,cex.axis=1.5)
>> 
>> box()
>> 
>> dev.off()
>> 
>> 
>> 
>> 
>> From:   Jannis <bt_jannis at yahoo.de>
>> To:     r-help at r-project.org
>> Date:   08/28/2013 05:32 PM
>> Subject:        Re: [R] Plotting time vs number
>> Sent by:        r-help-bounces at r-project.org
>> 
>> 
>> 
>> Hi Mohan,
>> 
>> i am not sure whether I understand your question correctly. Without
>> beeing able to easily reproduce your plot, I would guess that the
>> "breaks" come from the type='b' option you choose. When you use type
>> ='l', the line would be continuous (though the jumps would still be
>> there). If you need the points as well, use points() to plot a point
>> plot over the already existing line plot.
>> 
>> 
>> Does this solve your problem?
>> 
>> Jannis
>> 
>> On 28.08.2013 13:45, mohan.radhakrishnan at polarisft.com wrote:
>>> Hi,
>>> 
>>>       The plot function draws a broken line. The graph breaks when it
>> jumps
>>> from a lower value to a higher value with a big break in between. Why
>> does
>>> this type of data not use 'pch' or 'type'.
>>> 
>>> When I plot I don't indicate anywhere it is time.
>>> 
>>>> head(data)
>>>        Time  Kbytes     RSS Dirty Mode
>>> 1 11:42:02 2691296 1599796    1582736
>>> 2 11:43:42 2691396 1599804    1582744
>>> 3 11:45:22 2691496 1599804    1582744
>>> 4 11:47:02 2691596 1599812    1582752
>>> 5 11:48:42 2691696 1599816    1582756
>>> 6 11:50:22 2691796 1599820    1582760
>>> 
>>> plot(data$Time,data$Kbytes,type="b",col = "blue",  ylab="",
>>> xlab="",las=2,lwd=2.5, lty=1,cex.axis=1.5)
>>> 
>>> 
>>> Thanks,
>>> Mohan
>>> 
>>> 
>>> This e-Mail may contain proprietary and confidential information and is
>> sent for the intended recipient(s) only.  If by an addressing or
>> transmission error this mail has been misdirected to you, you are
>> requested to delete this mail immediately. You are also hereby notified
>> that any use, any form of reproduction, dissemination, copying,
>> disclosure, modification, distribution and/or publication of this e-mail
>> message, contents or its attachment other than by its intended
> recipient/s
>> 
>> is strictly prohibited.
>>> 
>>> Visit us at http://www.polarisFT.com
>>> 
>>>                [[alternative HTML version deleted]]
>>> 
>>> ______________________________________________
>>> R-help at 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.
>>> 
>> 
>> ______________________________________________
>> R-help at 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.
>> 
>> 
>> 
>> 
>> This e-Mail may contain proprietary and confidential information and is
>> sent for the intended recipient(s) only.  If by an addressing or
>> transmission error this mail has been misdirected to you, you are
>> requested to delete this mail immediately. You are also hereby notified
>> that any use, any form of reproduction, dissemination, copying,
>> disclosure, modification, distribution and/or publication of this e-mail
>> message, contents or its attachment other than by its intended
> recipient/s
>> is strictly prohibited.
>> 
>> Visit us at http://www.polarisFT.com
>> 
>>                  [[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help at 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.
>> 
>> 
>> 
>> 
>> This e-Mail may contain proprietary and confidential information and is
> sent for the intended recipient(s) only.  If by an addressing or
> transmission error this mail has been misdirected to you, you are
> requested to delete this mail immediately. You are also hereby notified
> that any use, any form of reproduction, dissemination, copying,
> disclosure, modification, distribution and/or publication of this e-mail
> message, contents or its attachment other than by its intended
> recipient/s
> is strictly prohibited.
>> 
>> Visit us at http://www.polarisFT.com
>> 
>>         [[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help at 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.
> 
> 
> 
> 
> This e-Mail may contain proprietary and confidential information and is
> sent for the intended recipient(s) only.  If by an addressing or
> transmission error this mail has been misdirected to you, you are
> requested to delete this mail immediately. You are also hereby notified
> that any use, any form of reproduction, dissemination, copying,
> disclosure, modification, distribution and/or publication of this e-mail
> message, contents or its attachment other than by its intended
> recipient/s is strictly prohibited.
> 
> Visit us at http://www.polarisFT.com
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.

____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails



More information about the R-help mailing list