[R-sig-eco] question for the R community : Plot RDA biplot without axis ?

Sarah Loboda sarah.loboda at gmail.com
Wed Mar 6 09:02:34 CET 2013


Hi :D
I finally had the chance to try your solutions. It was fast to modify
the code of the function and it worked!
I really appreciate your comments and your help. You are fast and clear !
I modified my code and I will never put white axes ever again ;)
Thank you very much.

2013/2/26 Jari Oksanen <jari.oksanen at oulu.fi>:
> Sarah,
>
> I added argument 'axis.bp' to text.cca and points.cca functions. To upgraded functions can be found in http://vegan.r-forge.r-project.org/ (rev2452), and will probably be included in the next minor release of vegan (2.0-7) scheduled for March, 2013.
>
> You can also get the single files from R-Forge, or you can install devel version of vegan with
>
> install.packages("vegan", repos="http://r-forge.r-project.org")
>
> It will take a day at minimum to get the version packaged in R-Forge.
>
> Cheers, Jari Oksanen
>
> On 26 Feb 2013, at 3:49, Sarah Loboda wrote:
>
>> Hi,
>> Here's the reproducible example that I made with dune data. When you do the
>> 4 graphs, you can see that because of the text () function, there is an
>> axis on the right and values appear in the plots on the right side. I
>> understand that it is because of my text () function, but is there a way to
>> delete that axis in the text funtion? if not, is there another way to plot
>> my data on 4 panels without axis?
>>
>> I don't know what you mean by "body of vegan text.cca". You mean in the
>> vegan tutorial ?
>> I used col.axis because ann=FALSE as an argument in plot function does not
>> work and col.axis seems fine...
>>
>> Thank you very much for your time. I really appreciate your help :D
>>
>> library(vegan)
>> library(MASS)
>>
>> ### data
>> data(dune)
>> data(dune.env)
>>
>> ### Constrained ordination
>> dune.hel<-decostand(dune, "hellinger")
>> dune.cca <- cca(dune ~ A1 + Manure, data=dune.env)
>>
>> ### Plot with 4 panels
>> par(mfrow=c(2,2))
>> par(mar=c(0.3,0.3,0.3,0.3))
>>
>>
>> ### plot 1
>> plot(dune.cca, type = "n", scaling = 2, col.axis="white")
>> with(dune.env, points(dune.cca, display = "sites", scaling = 2, cex=1.3,
>> col=2))
>> ### When I add the next line, it adds env. variables as arrows but also
>> adds an axis on the right
>> text(dune.cca, display="bp", col=1, cex=1.1)
>>
>> ###plot 2
>> plot(dune.cca, type = "n", scaling = 2, col.axis="white", col="grey")
>> with(dune.env, points(dune.cca, display = "sites", scaling = 2, cex=1.3,
>> col=2))
>> text(dune.cca, display="bp", col=1, cex=1.1)
>>
>> ###plot 3
>> plot(dune.cca, type = "n", scaling = 2, col.axis="white")
>> with(dune.env, points(dune.cca, display = "sites", scaling = 2, cex=1.3,
>> col=2))
>> text(dune.cca, display="bp", col=1, cex=1.1)
>>
>> ###plot 4
>> plot(dune.cca, type = "n", scaling = 2, col.axis="white")
>> with(dune.env, points(dune.cca, display = "sites", scaling = 2, cex=1.3,
>> col=2))
>> text(dune.cca, display="bp", col=1, cex=1.1)
>>
>> 2013/2/25 Gavin Simpson <gavin.simpson at ucl.ac.uk>
>>
>>> On Mon, 2013-02-25 at 13:18 -0500, Sarah Loboda wrote:
>>>> Hi,
>>>> I have trouble to obtain the ordination graph I want. I want to have 4
>>> RDA
>>>> biplot on the same page and I don't want to have (or I want to modify)
>>> the
>>>> axis numbers. I want the marks on the axis without numbers to maximize
>>> the
>>>> space for each RDA plot.
>>>
>>> A problem is the call to text() ( which calls text.cca() ). It doesn't
>>> pass on arguments to the underlying axis() calls and hence you can't do
>>> what you are trying to do with that function directly.
>>>
>>> Not sure why you want the axis to be white - that draws an axis so it
>>> will obscure anything drawn before it with white paint.
>>>
>>> The only solution at the moment will be to modify the vegan:::text.cca()
>>> function to change the two calls to axis() at the end of the function
>>> definition. I suspect you could just copy the body of vegan:::text.cca
>>> and put it into your own function, but I haven't tried it. If that fails
>>> due to namespace issues, then use assignInNamespace() to assign your
>>> function to the text.cca function in vegans namespace.
>>>
>>> See the relevant help pages on how to do this. I'm about to leave the
>>> office so I can't help further now, but if you have trouble email back
>>> to the list and I'll see about cooking up and example...
>>>
>>> All the best
>>>
>>> Gavin
>>>
>>>> This seems like a simple task but I tried different approaches and
>>> coudn't
>>>> figure out how to change my axis. This is my code :
>>>>
>>>> par(mfrow=c(2,2))
>>>> par(mar=c(0.2,0.2,0.2,0.2))
>>>>
>>>> ### first RDA biplot
>>>> with(arctic, levels(site))
>>>> shapevec<- c(19,19,19,19,19,19,19,19,19,19,19,19,6,6,6,6,6,6,6,6,6,6,6,6)
>>>> plot(spiders.rda.a, type = "n", scaling = 2, las=1, tcl=0.2,
>>>> col.axis="white")
>>>> with(spiders.env.a, points(spiders.rda.a, display = "sites",
>>>>                                scaling = 2, pch = shapevec, cex=1.3))
>>>> text(spiders.rda.a, display="bp", cex=1.1, col.axis="white", ann=FALSE)
>>>> #### it is when I run this line that my y axis appear on the right but I
>>>> don't want to
>>>> ### in yellow, this is what I tried to make it diseappear. To put those
>>>> arguments in plot() doesn't change anything.
>>>>
>>>> What should I had in the text part to make sure that the axis doesn't
>>> show
>>>> up?
>>>> My intention is to plot my sites as dots without text and my arrows for
>>>> environmental variables with the name of each variable. Any other ideas
>>> on
>>>> rda plot will be greatly appreciated.
>>>> Thank you very much :D
>>>>
>>>
>>>
>>>
>>>
>>
>>
>> --
>> Sarah Loboda
>> MSc candidate, Entomology,
>> Department of Natural Resource Sciences
>> McGill University
>> *http://insectecology.mcgill.ca/*
>>
>>       [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-ecology mailing list
>> R-sig-ecology at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>



-- 
Sarah Loboda
MSc candidate, Entomology,
Department of Natural Resource Sciences
McGill University
http://insectecology.mcgill.ca/



More information about the R-sig-ecology mailing list