[R-sig-eco] Re : Problem with Polygon

Sarah Goslee sarah.goslee at gmail.com
Mon Dec 12 19:52:00 CET 2011


Still no reproducible example, but it's likely that you need to reorder
the points: they're drawn in the order you specify. Compare:

plot(1:10, 1:10, type="n")
polygon(c(1, 2, 3, 6), c(1, 1, 8, 10))
polygon(c(1, 2, 6, 3)+4, c(1, 1, 10, 8))

You might instead want the convex hull, and code something like:
> pointdata <- data.frame(x=c(1, 2, 3, 6), y=c(1, 1, 8, 10))
> polygon(pointdata[chull(pointdata), ], col="blue")

But please, a small reproducible example next time.

Sarah

On Mon, Dec 12, 2011 at 1:19 PM, momadou sow <momadou at yahoo.fr> wrote:
> Thank you Sarah,
> To answer your request, I attached my output. It seem me bad because, when I
> drew the only variable (MeanArea)  the shape of the figure was generally
> concave.I suppose that my output with polygon function would take a close
> shape.
> Thank to you
> Momadou
>
> De : Sarah Goslee <sarah.goslee at gmail.com>
> À : momadou sow <momadou at yahoo.fr>
> Cc : "R-sig-ecology at r-project.org" <R-sig-ecology at r-project.org>
> Envoyé le : Lundi 12 Décembre 2011 19h39
> Objet : Re: [R-sig-eco] Problem with Polygon
>
> It's very hard to help you without:
> a small reproducible example;
> an idea of what you are getting vs what you expect - "does not seem
> good" is not particularly informative.
>
> Otherwise we really can't tell what's wrong.
>
> Sarah
>
> On Mon, Dec 12, 2011 at 12:26 PM, momadou sow <momadou at yahoo.fr> wrote:
>> Hi,
>> I have a
>> matrix with 3 columns (Date, MeanArea and SdArea). I want to draw a figure
>> showing
>> the variable MeanArea in terms ofthe
>> Date.
>> But instead to use the variable SdAreaas
>> bar error, I want to use “polygon error”. I use this code but the output
>> does
>> not seem good.
>>>Poly<read.table("C:\\Users\\Documents\\AreaMonthly.csv",sep=";",dec=",",header=TRUE)
>>>Poly
>>>y <-MeanArea
>>>x <-SdArea
>>>z <-Date
>>>matplot(x,cbind(y,z),type="n")
>>>polygon(c(x,rev(x)),c(y,rev(z)),col="grey50")
>> Thank
>> you in advance
>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>
>



-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org



More information about the R-sig-ecology mailing list