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

Jari Oksanen jari.oksanen at oulu.fi
Tue Feb 26 15:51:22 CET 2013


Sarah,

We indeed insist on drawing scale of arrows for text() and point() function of cca/rda/capscale. Currently the only way to avoid this is to edit the function. I'll see what to do with this.

One piece of advice: do not use col.axis = "white" which will draw white axes. The background of the graph is transparent but the plot is displayed on white canvas so that you cannot see white axes. The white axes are still, like you will see if you look at the graph against some other colour (which happens most easily if you copy the graph and display it in slides or in a poster with coloured background). The canonical way is to suppress axes:

plot(dune.cca, type="n", scaling = 2, axes = FALSE, xlab = "", ylab = "")

Here 'axes' suppress drawing axes and to be sure, xlab and ylab use zero-length strings "" so that axis labels are also suppressed. You can later use

box()

to frame the empty graph if needed.

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



More information about the R-sig-ecology mailing list