Re: [R] How add degree character in axis?

2006-06-09 Thread Roger D. Peng
Take a look at ?plotmath.

-roger

fernando espindola wrote:
 Hi user R,
 
 I am try to put degree character in axis x, but don't make this.  I have 
 the next code:
 
 plot(mot[,5], 
 time1,xlim=c(-45,-10),type=l,yaxt=n,ylab=,col=1,lwd=2,xlab=,xaxt=n)
 
 The range of value in axis-x  is  -45 to -10, this values represents the 
 longitudes positions in space. I try to put 45°S for real value (-45) in 
 the axis-x, and for all elements . Anybody can give an advance in this 
 problems.
 
 Thank for all
 
 

-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How add degree character in axis?

2006-06-09 Thread Marc Schwartz (via MN)
On Fri, 2006-06-09 at 11:01 +, fernando espindola wrote:
 Hi user R,
 
 I am try to put degree character in axis x, but don't make this.  I have 
 the next code:
 
 plot(mot[,5], 
 time1,xlim=c(-45,-10),type=l,yaxt=n,ylab=,col=1,lwd=2,xlab=,xaxt=n)
 
 The range of value in axis-x  is  -45 to -10, this values represents the 
 longitudes positions in space. I try to put 45°S for real value (-45) in 
 the axis-x, and for all elements . Anybody can give an advance in this 
 problems.
 
 Thank for all

In general, as Roger noted, see ?plotmath for adding mathematical
annotation to R plots.

To do the degree symbol is relatively straightforward, but adding the
S takes a bit of a trick:

# Create vector of x values
at - seq(-45, -10, 5)

# Create a mock plot
plot(at, 1:8, xlim = range(at), xaxt = n)

# Now create a set of plotmath expressions, one for 
# each value of 'at' using paste() and parse()
# The general format for the degrees symbol is x*degree
# However, to add the S we use the ~ to create 
# a right and left hand side for the expression and 
# place the S after it. The ~ will not print.
L - parse(text = paste(at, *degree ~ S, sep = ))

# Now do the x axis
axis(1, at = at, labels = L)


HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html