In R, the plot()
function takes a pch
argument that controls the appearance of the points in the plot. I'm making scatterplots with tens of thousands of points and prefer a small, but not too small dot. Basically, I find pch='.'
to be too small, but pch=19
to be too fat. Is there something in the middle or some way to scale the dots down somehow?
pch=20 returns a symbol sized between "." and 19.
It's a filled symbol (which is probably what you want).
Aside from that, even the base graphics system in R allows a user fine-grained control over symbol size, color, and shape. Eg,
dfx = data.frame(ev1=1:10, ev2=sample(10:99, 10), ev3=10:1)
with(dfx, symbols(x=ev1, y=ev2, circles=ev3, inches=1/3,
ann=F, bg="steelblue2", fg=NULL))
Try the cex
argument:
?par
cex
As rcs stated, cex
will do the job in base graphics package. I reckon that you're not willing to do your graph in ggplot2
but if you do, there's a size
aesthetic attribute, that you can easily control ( ggplot2
has user-friendly function arguments: instead of typing cex
(character expansion), in ggplot2
you can type eg size = 2
and you'll get 2mm point).
Here's the example:
### base graphics ###
plot(mpg ~ hp, data = mtcars, pch = 16, cex = .9)
### ggplot2 ###
# with qplot()
qplot(mpg, hp, data = mtcars, size = I(2))
# or with ggplot() + geom_point()
ggplot(mtcars, aes(mpg, hp), size = 2) + geom_point()
# or another solution:
ggplot(mtcars, aes(mpg, hp)) + geom_point(size = 2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.