[R] Use of colour in plots

Yihui Xie xieyihui at gmail.com
Fri Sep 19 06:41:39 CEST 2008


Hi Steve,

I don't know how large is your data, but I think usually
alpha-transparency can solve the problem of overplotting, if small
points won't work. For example, you can specify alpha = 0.1 in rgb()
to generate transparent colors and plot your data points. You may take
a look at the example 1 in: http://www.yihui.name/en/post/51.htm

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Fri, Sep 19, 2008 at 3:02 AM, Steve Murray <smurray444 at hotmail.com> wrote:
>
> Greg,
>
> Thanks for this - it works really well!
>
> One (hopefully final!) question I have is, is there any way of preventing overplotting? I'm finding that many of the red points are being obscured by the greens - I've tried making the point sizes small (cex=0.1) but this doesn't fully solve the problem.
>
> Or even, is there a way of changing the order of which the points are plotted?
>
> Thanks again,
>
> Steve
>
>
>
>
>> From: Greg.Snow at imail.org
>> To: smurray444 at hotmail.com; thierry.onkelinx at inbo.be; petr.pikal at precheza.cz; jrkrideau at yahoo.ca; jim at bitwrit.com.au
>> CC: r-help at r-project.org
>> Date: Thu, 18 Sep 2008 10:56:05 -0600
>> Subject: RE: [R] Use of colour in plots
>>
>> Try something like:
>>
>>> x <- runif(25)
>>> y <- rnorm(25)
>>> z <- rnorm(25, 3*x)
>>> plot(x, y, col=ifelse( z> 1.25, 'red', 'green') )
>>
>> Does this help,
>>
>> --
>> Gregory (Greg) L. Snow Ph.D.
>> Statistical Data Center
>> Intermountain Healthcare
>> greg.snow at imail.org
>> 801.408.8111
>>
>>
>>> -----Original Message-----
>>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
>>> project.org] On Behalf Of Steve Murray
>>> Sent: Thursday, September 18, 2008 8:14 AM
>>> To: ONKELINX, Thierry; Petr PIKAL; jrkrideau at yahoo.ca;
>>> jim at bitwrit.com.au
>>> Cc: r-help at r-project.org
>>> Subject: Re: [R] Use of colour in plots
>>>
>>>
>>> Jim and all,
>>>
>>> Maybe I've misunderstood ?color.scale (appologies if this is so), but I
>>> don't think this is what I need. I'm not looking to scale the colours
>>> of points, instead I simply want to assign each point a colour (either
>>> red or green) based on it's value in the Urban.Rural column.
>>>
>>> To clarify (but please also see my earlier message if this helps):
>>>
>>> In my dataset (Jan) I have 3 columns of interest: Average Burnt Area
>>> Fraction (ABAF), PopDensity and Urban.Rural.
>>>
>>> I want to plot ABAF against PopDens (which I've had no problems doing)
>>> and then, regardless of the values of ABAF and PopDens, I want to
>>> assign it a colour. The colour each point is given is based on the
>>> corresponding Urban.Rural value on each row. If for each pair of ABAF
>>> and PopDens values the Urban.Rural value on that row is>1.25, then the
>>> point should be coloured red, whereas if it's =
>>>
>>> ______________________________________________
>>> R-help at r-project.org 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.
>
> _________________________________________________________________
> Discover Bird's Eye View now with Multimap from Live Search
>
> ______________________________________________
> R-help at r-project.org 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.
>



More information about the R-help mailing list