Skip to content

Reset par(xaxp) in plot

3 messages · Yang, Richard, Peter Dalgaard, Uwe Ligges

#
R-Helpers;

	This seems simple to set graphic parameter, but I tried plot a graph
with 10 intervals in x axis with  par(xaxp = c(0, 150, 10) but to no avail:

	par(xaxp =c (0, 150,  10))
	plot(age, y18, type="n", ylab="Height (m)", xlab=" age (Yrs)", font
= 2)
	lines(age, y6, lty = 4, lwd = 2)
	lnes(age, y10, lty = 1, lwd =2)
	lines(age, y14, lty = 2, lwd =2)
	lines(age, y18, lty = 3, lwd = 2)
	abline(v=50)

The plot shown only 3 intervals with tick at 0, 50, 100, and 150. and
[1]   0 150   3

	I use current version Lattice and Grid.
_              
platform i386-pc-mingw32
arch     i386           
os       mingw32        
system   i386, mingw32  
status   Patched        
major    1              
minor    5.0            
year     2002           
month    05             
day      15             
language R          

	What did I miss?

Richard
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
"Yang, Richard" <dyang at nrcan.gc.ca> writes:
...
xaxp is a bit tricky since it gets calculated and *set* by routines
like plot. You can, however, plot without axes, set xaxp, and then use
axis():

 plot(1:10,axes=F)
 par(xaxp=c(1,10,99))
 axis(1)
 axis(2)
 box()

(Arguably, plot(1:10,xaxp=c(1,10,99)) could be coerced to work, but it
currently does not.)
#
"Yang, Richard" wrote:
With par("xaxp") you read the current status of the plot, you cannot set
it.
Use par("lab") for these purposes (only approx. number of intervals can
be given) or add the axis explicitly with axis(), e.g.:

  par("lab" = c(10,5,5))
  plot(...)

or better for your case:

  plot(..., xaxt = "n")
  axis(1, at = seq(0, 150, 15))
But not in the example above.

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._