[R] matplot help
ggrothendieck at gmail.com
Thu Jul 10 16:00:38 CEST 2008
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"
# 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, 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:
> 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.
> 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
>> 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,
>> 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
>> as an argument in xplot.
>> If you want to control where your tick marks (and therefore labels) go, try
>> ?par will give you the details.
>> On Wed, Jul 9, 2008 at 4:26 PM, Boyce, Morgan <mkboyce1 at uncc.edu> wrote:
>>> 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.
>>> 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!
>>> [[alternative HTML version deleted]]
>>> R-help at r-project.org mailing list
>>> 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
> 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
> R-help at r-project.org mailing list
> 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