[R] xyplot: adjusting the scale (min, max & tick)

Jay kmangs at cc.hut.fi
Thu Jan 7 02:10:32 CET 2010


Perfect, that piece of code did exactly what I wanted. However, I stumpled
upon a new problem, now my data is plotted on a totally wrong scale. The
y-values are all between 160k and 500k, BUT now with that option I find that
the plots are between 0 and 50 (?!?). What did I do wrong?

This plots the data OK, even thoug it should be between  160k and 500k on
the y-scale:

xyplot(data1[,2]+data1[,3]~data1[,1], data = data1,
        type = "l",
        xlab = "x",
        ylab = "y",
        auto.key = list(space="top", lines = T, points = F, text=c("text1",
text2")),
        par.settings = simpleTheme(lty = c(1,2)),
        scales=list(
          x=list(alternating=FALSE,tick.number = 11),
          y=list(limits=c(0,50))
        )     
        )   

If I remove the " y=list(limits=c(0,50))" the dat is plotted as it should.



Peter Ehlers wrote:
> 
> Have a look at the 'scales' argument. For example:
> 
> # default plot
> xyplot(Sepal.Length ~ Petal.Length | Species, data = iris)
> 
> # modified plot
> xyplot(Sepal.Length ~ Petal.Length | Species, data = iris,
>      scales=list(y=list(at=c(-5,0,5,10), limits=c(-5,10))))
> 
>   -Peter Ehlers
> 
> Jay wrote:
>> Hi,
>> 
>> I'm terribly sorry but it seems it cannot figure this one out by
>> myself so, please, if somebody could help I would be very grateful.
>> So, when I plot with xyplot() I get an y-axis that is very ugly...
>> starting from a random number and having so many ticks that it becomes
>> unreadable.
>> 
>> How do I tell xyplot how to draw the axis? E.g., start from 100, end
>> at 200 with 25 units between ticks/labels?
>> Can somebody give me an example?
>> 
>> Thanks!
>> 
>> ______________________________________________
>> 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.
>> 
>> 
> 
> -- 
> Peter Ehlers
> University of Calgary
> 403.202.3921
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://n4.nabble.com/xyplot-adjusting-the-scale-min-max-tick-tp999611p1008539.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list