[R] customise tick marks

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Wed Sep 12 11:58:27 CEST 2018


Hi Roslinazairimah,
You seem to be using the dotplot function from the lattice package. If so:

dotplot(cyl ~ mpg, data = mtcars, groups = cyl, cex=1.2,
 scales=list(y=list(labels=sort(unique(mtcars$cyl)))),
 main="Gas Milage for Car Models",  xlab="Miles Per Gallon")

Jim
On Wed, Sep 12, 2018 at 4:21 PM roslinazairimah zakaria
<roslinaump using gmail.com> wrote:
>
> Dear r-users,
>
> I want to draw dotplot for mtcars data according to cyl. There are three
> types of cylinder 4,6,8. However when we draw it does not use 4,6,8 instead
> label it as 1,2,3.
>
> I have this code and would like to customise the tick mark according to cyl
> groups:
>
>
> dotplot(cyl ~ mpg, data = mtcars, groups = cyl, cex=1.2,axes=FALSE,
>   main="Gas Milage for Car Models",  xlab="Miles Per Gallon")
> ticks = c(1,2,3)
> axis(2, at = ticks, labels=c(4,6,8))
>
> I got this message:
>
> axis(2, at = ticks, labels=c(4,6,8))
> Error in axis(2, at = ticks, labels = c(4, 6, 8)) :
>   plot.new has not been called yet
>
> Thank you so much for any help given.
> --
> *Roslinazairimah Zakaria*
> *Tel: +609-5492370; Fax. No.+609-5492766*
>
> *Email: roslinazairimah using ump.edu.my <roslinazairimah using ump.edu.my>;
> roslinaump using gmail.com <roslinaump using gmail.com>*
> Faculty of Industrial Sciences & Technology
> University Malaysia Pahang
> Lebuhraya Tun Razak, 26300 Gambang, Pahang, Malaysia
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list