The scales argument in lattice controls the appearance of the axes. It consists of two lists, one for the x axis and one for the y axis. For example:

histogram(~pesti[,1]|pesti[,2]+ pesti[,3],scales=list(x=list(at=c(2,6),labels=c("First","Second"))))

This allows you to place the labels wherever you want.

--Patrick


On 05/03/2011 05:49 PM, Andrew McFadden wrote:
Hi Patrick

The plot is an example ie not the real thing the x axes is a factor and
cant be numeric ie it is a titre of a laboratory test. If I change the
aspect ratio or the font size they still do not fit. How do you put
fewer labels on ie how do you tell R to skip every second label?

Regardes

Andrew McFadden MVS BVSc | Incursion Investigator (animals),
Investigation and Diagnostic Centre | Biosecurity New Zealand
Ministry of Agriculture and Forestry | 66 Ward St,  Wallaceville | PO
Box 40 742 | Upper Hutt | New Zealand
Telephone: 64-4-894 5611 | Facsimile: 64-4-894 4973| Mobile:
027-733-1791 | Web: www.maf.govt.nz


-----Original Message-----
From: Breheny, Patrick [mailto:patrick.breh...@uky.edu]
Sent: Wednesday, 4 May 2011 9:45 a.m.
To: Andrew McFadden; r-help@r-project.org
Subject: [Requires Classification] RE: Overlapping x axes using Lattice

I'm not clear on what you're looking for here.  Your x-axis is numeric,
why are you converting it to a factor?  If you keep it numeric, the
labels don't overlap.  Or perhaps you don't want it to be numeric, in
which case why not just change the aspect ratio of the plot until they
no longer overlap?  Or change the axis font size?  Or put fewer labels
on the axis?  There is a finite amount of space on the axis, so you have
to either make more space, shrink the labels, or draw fewer of them.


-----Original Message-----
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Andrew McFadden
Sent: Tuesday, May 03, 2011 5:05 PM
To: r-help@r-project.org
Subject: [R] Overlapping x axes using Lattice

Hi R users

I apologise in advance for this question as I suspect it is simple and
perhaps others have had this problem.
I am struggling to sort out how to fix the x axes so that the labels
don't overlap.

I have put the following example together to show my problem.

library(lattice)

titre<- as.factor(rep(c(10999,20999,30999,40999,50999,60999,
20000,40000,45000,50000,70000,80000),c(2,2,2,2,1,1,2,2,2,2,1,1)))
test<-rep(c("BVD","HSD"),c(10,10))
age<-as.factor(rep(c(1,2,3,4),c(5,5,5,5)))

pesti<-data.frame(titre,test,age)

histogram(~pesti[,1]|pesti[,2]+ pesti[,3]
,alternating=TRUE,tick.number=1, stack=TRUE,type = "count",
xlab="VNT",rot=c(180,180),draw=FALSE)

Thank you in advance.

Andy

Andrew McFadden MVS BVSc
Incursion Investigator
Investigation&  Diagnostic Centres - Wallaceville Biosecurity New
Zealand Ministry of Agriculture and Forestry

Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address:
Investigation and Diagnostic Centre- Wallaceville Box 40742 Ward St
Upper Hutt





This email message and any attachment(s) is intended solely for the
addressee(s)
named above. The information it contains is confidential and may be
legally
privileged.  Unauthorised use of the message, or the information it
contains,
may be unlawful. If you have received this message by mistake please
call the
sender immediately on 64 4 8940100 or notify us by return email and
erase the
original message and attachments. Thank you.

The Ministry of Agriculture and Forestry accepts no responsibility for
changes
made to this email or to any attachments after transmission from the
office.

        [[alternative HTML version deleted]]

______________________________________________
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.


This email message and any attachment(s) is intended solely for the addressee(s)
named above. The information it contains is confidential and may be legally
privileged.  Unauthorised use of the message, or the information it contains,
may be unlawful. If you have received this message by mistake please call the
sender immediately on 64 4 8940100 or notify us by return email and erase the
original message and attachments. Thank you.

The Ministry of Agriculture and Forestry accepts no responsibility for changes
made to this email or to any attachments after transmission from the office.



______________________________________________
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.

Reply via email to