Skip to content

replacing default axis labels on a plot

5 messages · Graves, Gregory, Duncan Murdoch, Uwe Ligges

#
I have 3 columns:  flow, month, and monthname, where month is 1-12, and
monthname is name of month.  I can't get the plot to replace the 1-12
with monthname using ticks.lab.  What am I doing wrong?

plot(flow~factor(month),xlab="Month",ylab="Total Flow per Month",
ylim=c(0,55000), ticks.lab="monthname")

Thanks

Gregory A. Graves
Lead Scientist
REstoration COoordination and VERification (RECOVER) 
Watershed Division
South Florida Water Management District
Phones:  DESK: 561 / 682 - 2429 
             CELL:  561 / 719 - 8157
#
On 14/05/2009 7:31 AM, Graves, Gregory wrote:
ticks.lab is not a parameter to the plot.formula function.  You don't 
say where you found it described, but I'd suggest you read your source 
more closely, or just use xaxt="n" in the plot call, and construct your 
own call to axis(), e.g. axis(1, at=1:12, labels=monthname).

Duncan Murdoch
#
Thanks.  But ... Still don't get it.

Referring explicitly to the monthname column which had many entries
across many years did not work.  So taking your clue I created a new
variable list of names of month

month.name<-list(c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct", "Nov", "Dec"))

then issued this command

plot(flow~factor(month),xlab="Month",ylab="Total Flow per Month",
ylim=c(0,55000), xaxt="n", axis(1, at=1:12, labels=month.name))

which gave this error

ERROR: 12, labels = month.name)

Gregory A. Graves
Lead Scientist
REstoration COoordination and VERification (RECOVER) 
Watershed Division
South Florida Water Management District
Phones:  DESK: 561 / 682 - 2429 
             CELL:  561 / 719 - 8157
             
 

-----Original Message-----
From: Duncan Murdoch [mailto:murdoch at stats.uwo.ca] 
Sent: Thursday, May 14, 2009 8:12 AM
To: Graves, Gregory
Cc: r-help at r-project.org
Subject: Re: [R] replacing default axis labels on a plot
On 14/05/2009 7:31 AM, Graves, Gregory wrote:
and
ticks.lab is not a parameter to the plot.formula function.  You don't 
say where you found it described, but I'd suggest you read your source 
more closely, or just use xaxt="n" in the plot call, and construct your 
own call to axis(), e.g. axis(1, at=1:12, labels=monthname).

Duncan Murdoch
http://www.R-project.org/posting-guide.html
#
Graves, Gregory wrote:
axis() is a separate function to be called *after* the call to plot().

Uwe Ligges
1 day later
#
The original problem posed was:
On 14/05/2009 7:31 AM, Graves, Gregory wrote:
and
Here is the solution to this:

# make a boxplot but suppress default labels on x axis with xaxt="n"

plot(flow~factor(month),xlab="Month",ylab="Total Flow per Month",
ylim=c(0,55000), xaxt="n")  #NOTE xaxt

# create a vector containing month abbrevs with [[1]] suffix as follows

month.name<-list(c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct", "Nov", "Dec"))[[1]]  

# place the 12 months on axis 1 (the x axis) as follows:
axis(1, at=1:12, labels=month.name)

Gregory A. Graves
Lead Scientist
REstoration COoordination and VERification (RECOVER) 
Watershed Division
South Florida Water Management District
Phones:  DESK: 561 / 682 - 2429 
             CELL:  561 / 719 - 8157