Re: [R] Data Labels in a barchart (Lattice or otherwise)

2010-07-07 Thread Greg Snow
> fortune(197)

If anything, there should be a Law: Thou Shalt Not Even Think Of Producing A
Graph That Looks Like Anything From A Spreadsheet.
   -- Ted Harding (in a discussion about producing graphics)
  R-help (August 2007)

Also read the discussion started with:
http://tolstoy.newcastle.edu.au/R/e2/help/07/08/22858.html



-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of RaoulD
> Sent: Sunday, July 04, 2010 9:44 PM
> To: r-help@r-project.org
> Subject: [R] Data Labels in a barchart (Lattice or otherwise)
> 
> 
> Hi,
> 
> Can anyone please help me with how I could add labels with the value
> for
> each bar in a barchart? (similar to how data labels can be added in
> Excel) I
> have done a lot of searching but havent been lucky.
> 
> Thanks,
> Raoul
> --
> View this message in context: http://r.789695.n4.nabble.com/Data-
> Labels-in-a-barchart-Lattice-or-otherwise-tp2278027p2278027.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@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.

__
R-help@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.


Re: [R] Data Labels in a barchart (Lattice or otherwise)

2010-07-05 Thread David Winsemius


On Jul 5, 2010, at 1:14 PM, RaoulD wrote:



Thank You David. Yes, I am using the lattice barchart and have  
managed to add

data labels, however, they tend to be on the tip of each bar and are
difficult to read as they are partially on the bar. Any help would be
greatly appreciated.

This is the code I am using:
levels(PR_SUMMARY$Bucket)=c("0-3 months","3-9 months","9-15  
months","15-18

months")
barchart(PrimaryReason ~ cInteractions| Bucket + Type, data =  
PR_SUMMARY,

layout = c(4, 2),col="lightgreen",main="COMPARISON - PRIMARY REASON",
  sub="L & R",xlab="Number of Customers",ylab="Primary  
Reasons",

  auto.key = list(title = "COMPARISON - PRIMARY
REASON",columns=2,points = FALSE, rectangles =  TRUE,space=  
"right"

),scales = list(x = list(abbreviate=TRUE,minlength=5,rot=45)),
  panel = function(x,y,subscripts,groups,...){
   panel.barchart(x,y,...)
   ltext(x,y,label=round(PR_SUMMARY$cInteractions,1),
cex=.99,rot=45)


# if you add or subtract a small amount from "y" in the prior line it  
will move the labels up or down.



   border="transparent"})

I dont really understand the "ltext" part and found it with some  
other code,

but it works.

Thanks again,
Raoul
--



David Winsemius, MD
West Hartford, CT

__
R-help@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.


Re: [R] Data Labels in a barchart (Lattice or otherwise)

2010-07-05 Thread RaoulD

Thank You David. Yes, I am using the lattice barchart and have managed to add
data labels, however, they tend to be on the tip of each bar and are
difficult to read as they are partially on the bar. Any help would be
greatly appreciated.

This is the code I am using:
 levels(PR_SUMMARY$Bucket)=c("0-3 months","3-9 months","9-15 months","15-18
months")
 barchart(PrimaryReason ~ cInteractions| Bucket + Type, data = PR_SUMMARY,
layout = c(4, 2),col="lightgreen",main="COMPARISON - PRIMARY REASON",
   sub="L & R",xlab="Number of Customers",ylab="Primary Reasons",
   auto.key = list(title = "COMPARISON - PRIMARY
REASON",columns=2,points = FALSE, rectangles =  TRUE,space= "right"
),scales = list(x = list(abbreviate=TRUE,minlength=5,rot=45)),
   panel = function(x,y,subscripts,groups,...){
panel.barchart(x,y,...)
ltext(x,y,label=round(PR_SUMMARY$cInteractions,1),
cex=.99,rot=45)
border="transparent"}) 

I dont really understand the "ltext" part and found it with some other code,
but it works.

Thanks again,
Raoul
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Data-Labels-in-a-barchart-Lattice-or-otherwise-tp2278027p2278646.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Data Labels in a barchart (Lattice or otherwise)

2010-07-05 Thread David Winsemius


On Jul 4, 2010, at 11:43 PM, RaoulD wrote:



Hi,

Can anyone please help me with how I could add labels with the value  
for
each bar in a barchart? (similar to how data labels can be added in  
Excel) I

have done a lot of searching but havent been lucky.


This is generally pretty easy with text() at least if you are using  
base graphics. If it is not clear after reading the help page then  
post an examply with whatever barchart function you have chosen to  
use. If it's the lattice barchart there is an ltext example  
immediately before the barchart example that quickly can be grafted  
into the barchart code.


David Winsemius, MD
West Hartford, CT

__
R-help@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.


[R] Data Labels in a barchart (Lattice or otherwise)

2010-07-05 Thread RaoulD

Hi,

Can anyone please help me with how I could add labels with the value for
each bar in a barchart? (similar to how data labels can be added in Excel) I
have done a lot of searching but havent been lucky.

Thanks,
Raoul
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Data-Labels-in-a-barchart-Lattice-or-otherwise-tp2278027p2278027.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.