# Re: [R] image/area plot

From: Marta Rufino <mrufino_at_cripsul.ipimar.pt>
Date: Fri, 18 Jan 2008 17:57:29 +0000

Thank you very much,
Best wishes,
Marta

> Do you have an example graphic that shows what you're trying to
> create? I can't figure out if you want something like a square pie
> chart (aka waffle chart), a stacked barchart, a levelplot, or
> something else.
>
>
> On Jan 18, 2008 6:06 AM, Marta Rufino <mrufino_at_cripsul.ipimar.pt> wrote:
>
>> Dear R users,
>>
>> I am trying to produce an image plot, that represents the proportions of
>> a factor (z variable), so that the number of squares of each colour
>> represents each factor level, with the respective label inside (sorry
>> for the crap English).
>>
>> # Something like this:
>>
>> kk=data.frame(fact=letters[1:10], freq=c(5,1,10,2,10,7,5,10,30,20)) #
>> factor and respective frequecies
>> res="a" # transform into a matrix (is there an easier way to do this?...
>> for the image plot
>> for(ii in 1:dim(kk)[1]){
>> res=c(res, rep(as.character(kk[ii,1]), l=kk[ii, 2]))
>> }
>> res=res[-1]
>> res
>> res=matrix(c(factor(res)), nc=10)
>>
>> image(x=1:10,y=1:10, res[,order(colSums(res))], col=rainbow(20))
>> abline(h=seq(0.5,10.5,1), col=8, lty=3); abline(v=seq(0.5,10.5,1),
>>
>> #Problems:
>> #1. How to add the labels in each area
>> text(1,1,paste("Factor level",kk[1,1]), pos=4)
>>
>> #2. How to separate the areas of each factor level (for BW printing),
>> with lines (instead of colours as it is)
>> segments(.5,1.5,5.5,1.5, lwd=2);segments(5.5,.5,5.5,1.5, lwd=2) #
>> something like this, but automatically :-(
>>
>> #3. How to keep the areas together (contiguous) and not allow split over
>> to lines?
>>
>> #4. Could I replace the col. by a symbol, for example? I think I would
>> need to use plot instead of image.
>> Any help will be much apretiated,
>>
>> Thank you very much in advance,
>> Best wishes,
>> Marta
>> PS: This type of graphs are used in community ecology analysis, for
>> example-...
>>
>> --
>> .......................................................................
>> Marta M. Rufino (PhD)
>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>
>
>

```--
.......................................................................
Marta M. Rufino (PhD)

.....
Instituto Nacional de Investigação Agrária e das Pescas (INIAP/IPIMAR),
Centro Regional de Investigação Pesqueira do Sul (CRIPSul)
Avenida 5 de Outubro s/n
P-8700-305 Olhão, Portugal
+351 289 700 541

.....
Institut de Ciències del Mar - CMIMA (CSIC)
Passeig Marítim de la Barceloneta, 37-49
08003 BARCELONA - Catalunya
Spain

[[alternative HTML version deleted]]

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
and provide commented, minimal, self-contained, reproducible code.
```
Received on Fri 18 Jan 2008 - 18:05:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 20 Jan 2008 - 23:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.