[R] Lattice(barchart) related query

Coltrey Mather r-help at cowsgomoo.org
Wed Jun 3 20:20:56 CEST 2009


No problem.  Sorry I ignored your font question, I have no personal
experience, but this may help:
https://stat.ethz.ch/pipermail/r-help/2009-April/196745.html

On Wed, Jun 3, 2009 at 10:17, Girish A.R. <garamach at gmail.com> wrote:
> Thanks, Coltrey! Option 1 is what I was looking for.
>
> -Girish
>
> On Jun 3, 8:05 pm, Coltrey Mather <r-h... at cowsgomoo.org> wrote:
>> barchart(mdat,
>>         groups=FALSE,
>>         layout=c(2,5),
>>         aspect=0.7,
>>         reference=FALSE,
>>         as.table=TRUE,
>>         main=list("Maintitle",cex=1),
>>         panel=function(x, y, ...) {
>>                 colours <- character()
>>                 colours[x < 0] <- 'red'
>>                 colours[x > 0] <- 'green'
>>                 panel.barchart(x, y, col=colours, ...)
>>         },
>>         xlab="x-axis labels"
>> )
>>
>> or:
>>
>> barchart(mdat,
>>         groups=FALSE,
>>         col=c(mdat < 0),
>>         layout=c(2,5),
>>         aspect=0.7,
>>         reference=FALSE,
>>         as.table=TRUE,
>>         main=list("Maintitle",cex=1),
>>         xlab="x-axis labels"
>> )
>>
>>
>>
>> On Wed, Jun 3, 2009 at 09:42, David Winsemius <dwinsem... at comcast.net> wrote:
>>
>> > On Jun 3, 2009, at 9:56 AM, Girish A.R. wrote:
>>
>> >> Hi,
>>
>> >> I have been recently experimenting with the lattice package, which I
>> >> must admit is just great! However, I'm sort of stuck in modifying
>> >> certain parameters; Would appreciate some pointers on a couple of
>> >> things:
>>
>> >> 1) Is it possible to change the font of the labels (say to computer
>> >> modern)  -- either in the Windows output or thru' Sweave (generating
>> >> EPS/PDF)?
>> >> 2) As you will notice, there are negative values in the data. Is it
>> >> possible to have a different color for the bars depicting negative
>> >> values?
>>
>> >> Reproducible code pasted below:
>>
>> >> ------------------------------------------------------------------------------------------
>> >> mdat <- matrix(c
>> >> (-2.65,-3.7,-0.8,-1.4,-2.39,-1.12,-4.78,-4.9,-0.76,-1.56,
>> >> 1.77,1.41,1.92,1.78,0.05,0.96,0.29,1.4,0.53,1.49,
>> >> 1.4,0.35,1.65,2.14,1.88,2.75,1.86,0.32,2.96,2.28), nrow = 3, ncol=10,
>> >> byrow=TRUE, dimnames = list(c("A", "B","C"),c
>> >> ("S-1","S-2","S-3","S-4","S-5","S-6","S-7","S-8","S-9","S-10")))
>>
>> >> barchart(mdat, groups=FALSE,layout=c
>> >> (2,5),aspect=0.7,reference=FALSE,as.table=TRUE,main=list("Main
>> >> title",cex=1),xlab="x-axis labels")
>>
>> > In you particular instance, I can accomplish the task but I do not know how
>> > to do it in a more general fashion, because I do not know how to access the
>> > values for the labels internally needed so that an ifelse() test can be
>> > constructed. See it this is helpful at any rate:
>>
>> > barchart(mdat, groups=FALSE,layout=c(2,5), aspect=0.7, reference=FALSE,
>> > as.table=TRUE, main=list("Main
>> > title",cex=1),xlab="x-axis
>> > labels",scales=list(x=list(col=c("red","red","black","black"))) )
>>
>> > Deepayan will probably be along shortly with the complete answer.
>>
>> > Regards;
>> > David
>>
>> > David Winsemius, MD
>> > Heritage Laboratories
>> > West Hartford, CT
>>
>> > ______________________________________________
>> > R-h... at r-project.org mailing list
>> >https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> 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