Point symbols in R

◇◆丶佛笑我妖孽 提交于 2019-12-07 06:18:13

问题


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.



来源:https://stackoverflow.com/questions/3739366/point-symbols-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!