[R] Plotting time vs number

jim holtman jholtman at gmail.com
Wed Aug 28 22:01:57 CEST 2013


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.



More information about the R-help mailing list