[R] change the height or scale of the y axis
Jim Lemon
jim at bitwrit.com.au
Thu Jun 25 13:54:36 CEST 2009
legen wrote:
> Hallo, All,
>
> I have a question about changing the height or scale of the y axis. When I
> use following two R codes, I can get two plots. Please look at the y axes,
> the number of indices (x1, x2, …) on the y axis in the first plot is smaller
> than that in the second plot, and hence the space between any two indices in
> the first plot is wider than that in the second plot. As the number of
> indices increases, the space will vanish and the indices will overlap. I
> want to display all the indices on the y axis in the second plot, just look
> like that in the first plot. How to separate the indices on the y axis in
> the second plot? I guess maybe changing the height or scale of y axis is a
> way to solve my problem, but I failed to do it after several trails. Anybody
> can help me? Thank you in advance.
>
> Legen
>
> The first R code:
> x<-c("x1","x2","x3","x4","x5","x6","x7","x8","x9","x10")
> y<-sample(0:100,10,replace=F)
> d<-data.frame(y)
> rownames(d)<-x
> r<-nrow(d)
> i<-1:r
> plot(d$y,i,xlab="",ylab="",axes=F)
> axis(1)
> axis(2,at=i,labels=x)
>
> The second R code:
> x<-c("x1","x2","x3","x4","x5","x6","x7","x8","x9","x10",
> "x11","x12","x13","x14","x15","x16","x17","x18","x19","x20",
> "x21","x22","x23","x24","x25","x26","x27","x28","x29","x30",
> "x31","x32","x33","x34","x35","x36","x37","x38","x39","x40",
> "x41","x42","x43","x44","x45","x46","x47","x48","x49","x50",
> "x51","x52","x53","x54","x55","x56","x57","x58","x59","x60",
> "x61","x62","x63","x64","x65","x66","x67","x68","x69","x70",
> "x71","x72","x73","x74","x75","x76","x77","x78","x79","x80",
> "x81","x82","x83","x84","x85","x86","x87","x88","x89","x90",
> "x91","x92","x93","x94","x95","x96","x97","x98","x99","x100",
> "x101","x102","x103","x104","x105","x106","x107","x108","x109","x110",
> "x111","x112","x113","x114","x115","x116","x117","x118","x119","x120",
> "x121","x122","x123","x124","x125","x126","x127","x128","x129","x130",
> "x131","x132","x133","x134","x135","x136","x137","x138","x139","x140",
> "x141","x142","x143","x144","x145","x146","x147","x148","x149","x150",
> "x151","x152","x153","x154","x155","x156","x157","x158","x159","x160",
> "x161","x162","x163","x164","x165","x166","x167","x168","x169","x170",
> "x171","x172","x173","x174","x175","x176","x177","x178","x179","x180",
> "x181","x182","x183","x184","x185","x186","x187","x188","x189","x190",
> "x191","x192","x193","x194","x195","x196","x197","x198","x199","x200")
> y<-sample(0:300,200,replace=F)
> d<-data.frame(y)
> rownames(d)<-x
> r<-nrow(d)
> i<-1:r
> plot(d$y,i,xlab="",ylab="",axes=F)
> axis(1)
> axis(2,at=i,labels=x)
>
>
Hi legen,
Your problem centers about the fact that you have about 3 times the
vertical scale on the second plot and 20 times the number of ticks and
labels. You could make the second plot 3 times the height of the first
one, and you would get approximately the same spacing of equal
intervals, but the intervals on the second plot are likely to be about
1.5 times those of the first. I can't work out why you are trying to do
what you say you want to do. Maybe some more explanation would help.
Jim
More information about the R-help
mailing list