R legend pch mix of character and numeric

前端 未结 5 1430
忘掉有多难
忘掉有多难 2020-12-31 04:28

Is it possible to use a mix of character and number as plotting symbols in R legend?

plot(x=c(2,4,8),y=c(5,4,2),pch=16)
points(x=c(3,5),y=c(2,4),pch=\"+\")
l         


        
5条回答
  •  没有蜡笔的小新
    2020-12-31 04:49

    There are actually numerical equivalents for all symbols!

    Source: Dave Roberts

    The pch code is the concatenation of the Y and X coordinates of the above plot.

    • For example, the + symbol is in row (Y) 4 and column (X) 3, and therefore can be drawn using pch = 43.

    Example:

    plot(x=c(2,4,8),y=c(5,4,2),pch=16)
    points(x=c(3,5),y=c(2,4),pch="+")
    legend(7,4.5,pch=c(43,16),legend=c("A","B"))
    

提交回复
热议问题