0

G'day

I have plotted a combination bar and line graph using twoord, with finical years as the x axis.

Please see example

a=c(50,75,80,100,110) 
b=c(500,750,800,1000,1100) 
finyr=c("2001-02","2002-01","2003-04","2004-05","2005-06") 
twoord.plot(finyr,a,finyr,b,
            type=c("bar","l"),
            ylab="a",rylab="b",xlab="Financial year",
                        lcol=32,rcol=4,do.first="plot_bg()")

Because financial year is a character, it returns the following error message

Error in plot.window(...) : invalid 'xlim' value In addition: Warningmessage: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion

I can create the graph I want by just using 2001, 2002 etc instead of financial year, but would like financial year as the x axis label. Is there a way to re-label the axis? Is there another way of producing this graph that allows characters for the x axis?

Thanks Matt

1 Answers1

2

I think you're looking for the xticklab argument. You can give the ticks whatever labels you like:

finyrNum <- 1:5
twoord.plot(finyrNum,a,finyrNum,b,
            type=c("bar","l"),
            ylab="a",rylab="b",xlab="Financial year",
            lcol=32,rcol=4,do.first="plot_bg()", xticklab=finyr)

enter image description here

alexwhan
  • 15,636
  • 5
  • 52
  • 66