[R] axis scale issues....

jim holtman jholtman at gmail.com
Tue Sep 29 18:15:07 CEST 2009


Not sure exactly what you want, but does using 'ylim' do what you want:

plot(1:5, sample(100:200,5), type='b', ylim=c(0,450))


On Tue, Sep 29, 2009 at 12:08 PM, chipmaney <chipmaney at hotmail.com> wrote:
>
> I have read all the help on axis scales, which seems to be much harder to
> deal with than it should be, given how common the need to alter axes.
> Anyway....yeah, suppress the axis using yaxt then call and define the new
> scale using axis().
>
> The problem is, this doesn't change the actual axis, only the text.
> Example:
>
> plot(1:length(TreeDensity.df$Description[which(TreeDensity.df$Description ==
> Zone.df[i])]),TreeDensity.df$CumMeanTree[which(TreeDensity.df$Description ==
> Zone.df[i])],
>                type = "b", sub=Zone.df[i],xlab="Sample Size",ylab = "Tree Density",
> yaxt="n")
>
>                axis(side = 2, xpd=FALSE, at = pretty(range(0,450)) )
>
> This code produces the following plot:
>
> http://www.nabble.com/file/p25665902/Presentation1.jpg
>
>
> Note that while the scale of the axis TEXT has changed, the actual axis
> scale hasn't, it still ranges across the value of the data....That is, the
> ranges 0...~100 and ~200....450 do not appear on the plot.
>
> One could say that the axis scale has changed, but part of the axis isn't
> showing up, so one could use xpd to suppress clipping....However, then the
> axis either runs off the device window or something, like the following
> plot:
>
> http://www.nabble.com/file/p25665902/Presentation2.jpg
>
> So, what I really want to do is not the change both the range (to 0...450)
> AND scale (ie, shrink the length of the range(0,450) to fit the existing
> plot dimensions) of the axis.  Any suggestion on how to accomplish this?
>
> Thanks in advance...
> --
> View this message in context: http://www.nabble.com/axis-scale-issues....-tp25665902p25665902.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list