[R] Tick mark puzzle.

Bert Gunter gunter.berton at gene.com
Tue Nov 13 01:35:52 CET 2007


Well, let me have a crack at it ... (inline below) 


Bert Gunter
Genentech Nonclinical Statistics


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Rolf Turner
Sent: Monday, November 12, 2007 2:16 PM
To: r-help at r-project.org
Subject: [R] Tick mark puzzle.


I am bewildered by the behaviour of tickmarks as demonstrated by the
following code.  (What I'm trying to do is draw a single tick mark  
extending
from the axis all the way down to the tick label, which is two lines  
from
the axis to make sure it doesn't overlap with the ``ordinary'' tick  
labels.)

# Try 1:
# Gap between tickmark and label.
plot(1:10)
axis(side = 1, at = 2.35, labels = "2.35", tick = TRUE,
      tcl=1,line=1,col="red", col.axis = "red")
readline('Go? ')

## From the first line position, below the plotting region (line =1) the
tick mark is
## drawn up 1 line height of text to the 0 position at the edge of the
plotting region
## The label is drawn below the line =1 position, leaving the gap

# Try 2:
# Gap between tickmark and axis.
plot(1:10)
axis(side = 1, at = 2.35, labels = "2.35", tick = TRUE,
      tcl=-1,line=1,col="red", col.axis = "red")
readline('Go? ')

## From the first line position one line height below the graph the tick
mark is drawn down to where
## the label is located, leaving the gap between tick mark and graph
boundary.

# Try 3:
# Gap between tickmark and label not filled.
plot(1:10)
axis(side = 1, at = 2.35, labels = "2.35", tick = TRUE,
tcl=1,line=1,col="red", col.axis = "red")
axis(side = 1, at = 2.35, labels ="", tick = TRUE, tcl=-1,col="red")

readline('Go? ')

## First axis command as in Try 1. Second command uses default line = 0 =
edge of plot region
## and so redraws tick the "other way" (down instead of up; try the second
axis it in a different ## color and you'll see it overplot the tick in the
different color)

# Try 4:
# Gap between tickmark and label ***is*** filled.
# Gives what I want, but ***why***?
plot(1:10)
axis(side = 1, at = 2.35, labels = "2.35", tick = TRUE,
      tcl=-1,line=1,col="red", col.axis = "red")
axis(side = 1, at = 2.35, labels ="", tick = TRUE, tcl=-1,col="red")

## Well you should be able to figure this one out now, right ... ;-)

Cheers,
Bert



More information about the R-help mailing list