[R] How to draw plot marks without label?

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Tue Sep 5 23:33:34 CEST 2023


For base R graphics, you should always consult ?par for optional graphical
parameters when the high level graphics function doesn't appear to provide
the control you would like. I don't use base graphics -- i.e. i"m not
particularly facile with it -- but as you provided an example, I decided to
try to help. I think this is what you may want:

           Y ~ X, data = df,  ## better way to specify data  instead of $
           method = "jitter", offset=1/3,
           vertical = TRUE, las=1,
           pch=16, cex=2,
           ylab="Y", xlab="X",
           yaxt= "n",  ## don't plot y axes

## Now add y axis on right with default tick mark locations
axis(side = 4, labels = FALSE)

How I got this (you may find this useful to modify the above if I didn't
get what you wanted) was as follows:

stripchart() does not seem to allow the direct control over the axes you
want. The 'axes' parameter help in ?stripchart sent me to?par to see if I
could specify an axis on the right instead of on the left, but it did not
seem to provide such an option. So I decided to use what the yaxt parameter
described to omit the y axis in the high level (stripchart) call, and then
add it back with a subsequent call to axis(). I just used default tick
locations in that call, but you can specify them explicitly as ?axis

Again, if this is not what you wanted, I hope you can use the above to
modify stripchart() to your desired specification.


On Tue, Sep 5, 2023 at 12:57 PM Luigi Marongiu <marongiu.luigi using gmail.com>

> I would like to draw a graph where the y-lables are missing but the
> marks still present.
> In this example, I get marks from 20000 to 140 000 with increments of
> 20 000. I could use `plot(... yaxt="n"...)` combined with `axis(2,
> at..., label="")` but this needs to know exactly the sequence of marks
> provided by plot. But this sequence might change.
> Thus is there a way to plot the marks without labels?
> Also, is it possible to draw the marks on the right side?
> Thank you.
> ```
> y = c(42008, 19076, 150576, 48192, 26153, 37931, 36103, 17692,
>       61538,41027, 71052, 94571)
> df = data.frame(X = c(rep(0, 6), rep(25, 6)), Y = y)
> stripchart(df$Y ~ df$X,
>            method = "jitter", offset=1/3,
>            vertical = TRUE, las=1,
>            pch=16, cex=2,
>            ylab="Y", xlab="X",
>            main="Example")
> ```
> ______________________________________________
> 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.

	[[alternative HTML version deleted]]

More information about the R-help mailing list