Re: [R] matplot help

From: Boyce, Morgan <mkboyce1_at_uncc.edu>
Date: Tue, 15 Jul 2008 15:32:58 -0400

Thank you both.  

I managed to accomplish this tack with your help.  

date = ts(time, start =1985, freq =4)
quarters = as.Date(time(date))
z = length(quarters)  

win.graph()
par(mfrow=c(1,1),mex=0.7,bg="white")
matplot(1:n,corp.check,type="l",lty=1, col=2, ylab="$",xlab="",xaxt="n")  title(main="Checkable Deposits & Currency", cex=0.5)  axis(1, at=1:z, labels=quarters)


From: Gabor Grothendieck [mailto:ggrothendieck_at_gmail.com] Sent: Thu 7/10/2008 10:00 AM
To: Boyce, Morgan; Michael Rennie
Cc: r-help_at_r-project.org
Subject: Re: [R] matplot help

Try this:

Lines <- "Q1-60 26.528 1.268

Q2-60 27.535 1.087
Q3-60 27.737 1.346
Q4-60 28.243 3
Q1-61 26.462 3.272
Q2-61 27.769 3.863
Q3-61 27.903 4.606
Q4-61 31.673 4.1
Q1-62 28.211 5.395
Q2-62 29.469 5.554
Q3-62 30.249 4.903"

library(zoo)
# z <- read.zoo("myfile.dat", FUN = as.yearqtr, format = "Q%q-%y") z <- read.zoo(textConnection(Lines), FUN = as.yearqtr, format = "Q%q-%y") colnames(z) <- c("A", "B")

# 60 should mean 1960, not 2060
time(z) <- time(z) - 100

plot(z)
plot(z, screen = 1, col = 1:2)

On Thu, Jul 10, 2008 at 9:34 AM, Michael Rennie <mdrennie_at_gmail.com> wrote:
> I think the problem is that you are trying to plot non-numeric values
> on your x. I built some test code around your example; I don't think
> you can plot non-numeric characters. If the plot is working on your
> end, it's likely because it's recognizing your X variable as a factor
> and it's plotting the numeric equivalents of the ordered factor. I
> think all you need to do is just call the plot without an x-axis and
> then make your own:
>
> ########################
>
> x<-c("a","b","c","d")
> y<-c(25,26,27,28)
>
> matplot(1:4, y, type="l",lty=1, col=2, ylab="Bil.$",xlab="Quarters w/
> Q1.60 = 0", xaxt="n")
> title(main="(Log Diff) Gross Domestic Product (SAAR)", cex=0.5)
> axis(1, at=1:4, labels=x)
>
> ########################
>
> Instead of "x" in axis() above, you can specify levels(x) and I think
> that should work, too.
>
> see ?axis for details.
>
> HTH,
>
> Mike
>
>
>
> On Thu, Jul 10, 2008 at 9:08 AM, Boyce, Morgan <mkboyce1_at_uncc.edu> wrote:
>>
>>
>> .DESC Checkable Deposits & Currency (Bil.$) Assets: Time and Savings Deposits (Bil.$)
>> Q1-60 26.528 1.268
>> Q2-60 27.535 1.087
>> Q3-60 27.737 1.346
>> Q4-60 28.243 3
>> Q1-61 26.462 3.272
>> Q2-61 27.769 3.863
>> Q3-61 27.903 4.606
>> Q4-61 31.673 4.1
>> Q1-62 28.211 5.395
>> Q2-62 29.469 5.554
>> Q3-62 30.249 4.903
>>
>> Mike,
>>
>> Is there a way to have the .DESC vector as the values on the X-axis? I tried 'xlim' but it didn't recognize Q1-60, Q3-62.
>>
>> Using 'xaxp' it appears that it can not handle non-numeric arguments? Am I missing something?
>>
>> Thanks again,
>>
>> Morgan
>> ________________________________
>> From: Michael Rennie [mailto:mdrennie_at_gmail.com]
>> Sent: Thu 7/10/2008 12:27 AM
>> To: Boyce, Morgan
>> Subject: Re: [R] matplot help
>>
>> I'm not entirely sure what the issue is given that you haven't supplied any data with the sample code. If you just want to limit your x axis, try
>>
>> 'xlim=c(xmin,xmax)'
>>
>> as an argument in xplot.
>>
>> If you want to control where your tick marks (and therefore labels) go, try
>>
>> xaxp
>>
>> ?par will give you the details.
>>
>> Mike
>>
>> On Wed, Jul 9, 2008 at 4:26 PM, Boyce, Morgan <mkboyce1_at_uncc.edu> wrote:
>>>
>>> Hi,
>>>
>>> My question is how do I gain control over what values the X and Y axis show. Below is a sample plot I have made and want the X axis to represent a time vector with values taking the form Q1.60, Q2.60, Q3.60...Q1.90..etc...Currently the X axis starts with value 0 and increases by 1 through the end of the sample.
>>>
>>>
>>> win.graph()
>>> matplot(v.0,log.diff.v.6,type="l",lty=1, col=2, ylab="Bil.$",xlab="Quarters w/ Q1.60 = 0")
>>> title(main="(Log Diff) Gross Domestic Product (SAAR)", cex=0.5)
>>>
>>> Any advice is greatly appreciated!
>>>
>>> Morgan
>>>
>>>
>>> [[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.
>>
>>
>>
>> --
>> --
>> Michael D. Rennie
>> Ph.D. Candidate
>> University of Toronto at Mississauga
>> 3359 Missisagua Rd. N.
>> Mississauga, ON L5L 1C6
>> Ph: 905-828-5452 Fax: 905-828-3792
>> www.utm.utoronto.ca/~w3rennie
>
>
>
> --
> --
> Michael D. Rennie
> Ph.D. Candidate
> University of Toronto at Mississauga
> 3359 Missisagua Rd. N.
> Mississauga, ON L5L 1C6
> Ph: 905-828-5452 Fax: 905-828-3792
> www.utm.utoronto.ca/~w3rennie
>
> ______________________________________________
> 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.
>

        [[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. Received on Tue 15 Jul 2008 - 20:50:57 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 15 Jul 2008 - 21:32:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive