[R] Plotting symbols with two positions?
Dimitris Rizopoulos
dimitris.rizopoulos at med.kuleuven.be
Thu Nov 9 11:46:39 CET 2006
I think you need the following:
attach(DAT.nr)
plot(jd.s, jd.h, type = "n")
text(jd.s, jd.h, t_no)
I hope it works.
Best,
Dimitris
----- Original Message -----
From: "CG Pettersson" <cg.pettersson at evp.slu.se>
To: "Dimitris Rizopoulos" <dimitris.rizopoulos at med.kuleuven.be>
Cc: "CG Pettersson" <cg.pettersson at evp.slu.se>;
<r-help at stat.math.ethz.ch>
Sent: Thursday, November 09, 2006 11:37 AM
Subject: Re: Plotting symbols with two positions?
> Dear Dimitris,
>
> Thanks a lot, but I didn't really manage to apply it in my context,
> I
> first got an error message and then an ugly plot.
>
> I have also got the advice from Gabor Grothendieck to use letters
> instead
> of numbers, but I do prefer numbers as this is the normal way of
> referring
> to the individual trials.
>
> This is what I did, (and failed with):
>
>> attach(DAT.nr)
>> plot(jd.s,jd.h, type = "no")
> Warning message:
> plot type 'no' will be truncated to first character in: plot.xy(xy,
> type,
> pch, lty, col, bg, cex, lwd, ...)
>
> This was not very hopeful, but as an empty frame was produced in the
> same
> time, I took a risk with this:
>
>> text(jd.s, jd.h, pch=as.character(DAT.nr$t_no))
>
> Which, to my surprise, produced a plot. The problem with it was
> _not_ that
> the numbers were truncated into the first (as could be expected) but
> that
> it seems like the line number, and not the trial number, were used.
> Not
> very nice as they number up to 576 and have 36 levels for each
> trial......
>
> If I instead use the last expression, but as a "plot":
>
>> plot(jd.s, jd.h, pch=as.character(DAT.nr$t_no))
>
> I am back where I begun with the correct numbers, but only the first
> position of it.
>
> What is happening?
>
> All the best
> /CG
>
> On Thu, November 9, 2006 10:19 am, Dimitris Rizopoulos said:
>> try this:
>>
>> y <- rnorm(16)
>>
>> plot(y, type = "n")
>> text(1:16, y, 1:16)
>>
>>
>> Best,
>> Dimitris
>>
>>
>>
>>
>> ----- Original Message -----
>> From: "CG Pettersson" <cg.pettersson at evp.slu.se>
>> To: "Dimitris Rizopoulos" <dimitris.rizopoulos at med.kuleuven.be>
>> Cc: "CG Pettersson" <cg.pettersson at evp.slu.se>;
>> <r-help at stat.math.ethz.ch>
>> Sent: Thursday, November 09, 2006 10:09 AM
>> Subject: Plotting symbols with two positions?
>>
>>
>>> Thanks a lot to Demitris for a prompt answer some minutes ago on
>>> another
>>> tread (see below). To avoid excess mails on the list, I move onto
>>> next
>>> question:
>>>
>>> I have another small plotting problem that confuses me. I want to
>>> plot
>>> results from a field trial series, using the numbers of the trials
>>> as
>>> symbols in the plot.
>>>
>>> pch = as.character(trial_no)
>>>
>>> works fine, but truncates the trial number to the first digit. As
>>> I
>>> have
>>> sixteen trials in the series I get into problems....
>>>
>>> How do I squeeze in two positions as a symbol in a plot?
>>>
>>> All the best
>>> /CG
>>>
>>>
>>> On Thu, November 9, 2006 9:30 am, Dimitris Rizopoulos said:
>>>> try the following:
>>>>
>>>> x <- runif(100, -4, 4)
>>>> y <- 1 + 2 * x + rnorm(100, sd = 2)
>>>> fit <- lm(y ~ x)
>>>>
>>>> plot(x, y)
>>>> abline(fit)
>>>> legend("topleft", expression(paste(R[adj]^2, " = 0.66")))
>>>>
>>>> ## or
>>>>
>>>> plot(x, y)
>>>> abline(fit)
>>>> legend("topleft", legend = substitute(R[adj]^2 == x,
>>>> list(x = summary(fit)$adj.r.squared)))
>>>>
>>>>
>>>> I hope it helps.
>>>>
>>>> Best,
>>>> Dimitris
>>>>
>>>> ----
>>>> Dimitris Rizopoulos
>>>> Ph.D. Student
>>>> Biostatistical Centre
>>>> School of Public Health
>>>> Catholic University of Leuven
>>>>
>>>> Address: Kapucijnenvoer 35, Leuven, Belgium
>>>> Tel: +32/(0)16/336899
>>>> Fax: +32/(0)16/337015
>>>> Web: http://med.kuleuven.be/biostat/
>>>> http://www.student.kuleuven.be/~m0390867/dimitris.htm
>>>>
>>>>
>>>> ----- Original Message -----
>>>> From: "CG Pettersson" <cg.pettersson at evp.slu.se>
>>>> To: <r-help at stat.math.ethz.ch>
>>>> Sent: Thursday, November 09, 2006 9:10 AM
>>>> Subject: [R] Why do I get a linebreak in the legend?
>>>>
>>>>
>>>>> Dear all,
>>>>>
>>>>> W2k, R2.4.0
>>>>>
>>>>> I want to place a legend in a regression plot, stating the
>>>>> adjusted
>>>>> R-square value. After some struggle with the coding I am nearly
>>>>> there, but
>>>>> only nearly. The best try so far is:
>>>>>
>>>>> legend("topleft", expression(paste(R[adj]^2), " = 0.66"))
>>>>>
>>>>> This places the proper information in the legend, but I get a
>>>>> linebreak
>>>>> before the "= 0.66" and I want the expression on one single
>>>>> line.
>>>>> All
>>>>> adjustments from this code I have tried so far either produces
>>>>> only
>>>>> half
>>>>> the expression or produces an error message.
>>>>>
>>>>> All the best and sorry for a trivial quastion
>>>>> /CG
>>>>>
>>>>>
>>>>> --
>>>>> CG Pettersson, MSci, PhD Stud.
>>>>> Swedish University of Agricultural Sciences (SLU)
>>>>> Dep. of Crop Production Ekology. Box 7043.
>>>>> SE-750 07 Uppsala, Sweden
>>>>> cg.pettersson at vpe.slu.se
>>>>>
>>>>> ______________________________________________
>>>>> R-help at stat.math.ethz.ch 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.
>>>>>
>>>>
>>>>
>>>> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
>>>>
>>>
>>>
>>> --
>>> CG Pettersson, MSci, PhD Stud.
>>> Swedish University of Agricultural Sciences (SLU)
>>> Dep. of Crop Production Ekology. Box 7043.
>>> SE-750 07 Uppsala, Sweden
>>> cg.pettersson at vpe.slu.se
>>>
>>
>>
>> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
>>
>
>
> --
> CG Pettersson, MSci, PhD Stud.
> Swedish University of Agricultural Sciences (SLU)
> Dep. of Crop Production Ekology. Box 7043.
> SE-750 07 Uppsala, Sweden
> cg.pettersson at vpe.slu.se
>
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
More information about the R-help
mailing list