Using pch Characters in grid.text

2019-07-04 02:49发布

问题:

I have created a graph using ggplot2. Now I want to have the legend not onto the graph but in the grid outside the graph.

My question is now if someone knows if there is a possibility to use the pch symbols in grid.text?

Here is an image to show what I want ;)

Best regards

回答1:

I don't know if we can directly use points in text, but you can combine grid.text and grid.points:

grid.points(x=rep(0.1,9),y=1:9/10,pch=1:10,default.units="npc")
grid.text(x=rep(0.2,9),y=1:9/10,label=letters[1:9],default.units="npc")


标签: r ggplot2 r-grid