Point symbols in R

2019-05-02 11:17发布

问题:

There are 25 symbols defined by 'pch' paramter in the points function.

How can I draw more than these 25 symbols

Thanks

回答1:

You can see all the options for a given font using code like:

plot( 0:15, 0:15, type='n' )
points( (0:255)%% 16, (0:255) %/% 16, pch=0:255, font=5 )

Change the font= to different numbers for different options. There are a couple more options using the symbols function. If you want even more then check out the my.symbols function in the TeachingDemos package (I am the author of my.symbols and most of the TeachingDemos package). There are several symbols available already and it gives an option for creating your own custom symbols, so there really is no limit.



回答2:

You can use the basic plotting and drawing functions to devise your own symbols. Use 'lines' or 'segments' for drawing lines and 'polygon' for filled areas. So you might have a function called 'littleHouse' that takes x,y for the centre and w and h for width and height, then you would do something like:

for(i in 1:nrows(data)){
 di = data[i,]
 littleHouse(di$x,di$y,di$w,di$h)
}

Being any more specific is probably a waste of time unless you've got anything specific in mind. You can't do it via the pch parameter.



回答3:

You just can't... only this set is implemented. Some option is to use character vectors (eg. pch=c('a','b','c')) to get points marked by as, bs, ... -- this extends the set to about 60 (with numbers), but does not look too well.